My java program creates a process in the following manner:
ProcessBuilder builder = new ProcessBuilder("phantomjs.exe crawl.js");
Process proc = builder.start();
In case the java program terminates abruptly (could always happen), the phantomjs process (which is not a java process) could stay alive and there would be no way to terminate it.
I want the phantomjs process to be terminated when the enclosing java process terminates (whether abruptly or not).
Is there a way to define the Process
instance as a "daemon" object that terminates automatically when its super process (which is the java process executing the code above) terminates?
Process
instance as a "daemon" object that terminates all of its sub-processes when terminating?" - and in your example, theProcess
instance is phantomjs.exe. – Pacianphantomjs.exe
. See blogs.technet.com/b/wincat/archive/2011/08/25/… – Pickett