I have a Java process that runs a program using Runtime.getRuntime (). exec ("myBin")
this "myBin" can evolve several times to finish the job.
I have a stream of readers to read all the output of "myBin" and its children from the InputStream and ErrorStream of the Process object returned by exec ()
My question is: if it takes too much time to complete the task, I need to kill the process and wait for the reader stream to finish (the read stream will end if it reads EOF)
Now I found that even I use Process.Destroy (), I can only kill "myBin" from myself and all my children. Therefore, after the timeout, EOF did not reach, so the reader flow freezes until all child processes stop ...
Is there a way to execute the safty kill process and all children running Runtime.exec ()
I am in Linux, cross-platform is not in my mind.
source share