How to launch another shell script as a background process?


(vipss78) #1

How to launch another shell script as a background process?

I am launching another shell script, which runs forever, but gradle keeps waiting for that process to be terminated, and eventually the gradle hangs and keeps waiting for that process to finish. How do I launch that shell script as a background process without making gradle wait for that process to finish?


(Peter Niederwieser) #2

Gradle’s ‘(Java)Exec’ task doesn’t support this, but you can use the normal Java means (e.g. ‘java.lang.ProcessBuilder’).


(vipss78) #3

Thanks for replying… but can you give me an example? Does executor supports this kind of handling?


(vipss78) #4

Thanks peter… but I got it… Thanks for the clue.


(Peter Niederwieser) #5

I should have mentioned that there is also Groovy’s ‘String.execute()’, where the string is the command line to execute. Like ‘ProcessBuilder’, it returns a ‘Process’ for further handling.


(vipss78) #6

Yes… its there… but it hangs the entire build process… since my shell script is never ending process… I tried that one… before posting questionhere…


(Peter Niederwieser) #7

Groovy’s ‘String.execute()’ returns immediately, just like ‘ProcessBuilder.start()’ (I double-checked). You must have done something different.


(vipss78) #8

All right… I will double check…