linux - Java Process.Destroy() does not kill all process -
i have java process launch program using runtime.getruntime().exec("mybin")
this "mybin" may fork several times finish job.
i have reader thread read output of "mybin" , children, inputstream , errorstream of process object returned exec()
my question is: if taks time finish job, need kill process , wait reader thread complete.(the reader thread complete if have read eof)
now found, use process.destroy(), can kill "mybin" insead of , children. after time-out, eof never reached, reader thread hang until children process terminated...
is there way safty kill process , children launched runtime.exec()
i on linux, cross-platform not in mind.
one way achieve have process invokes fork save list of children pids. implement handler in mybin triggers kill "childrens".
another option use threads instead of using forks.
the main problem why not work if invoke fork create new process has no real dependency parent process.
Comments
Post a Comment