Question

I have written a Java program to run some other processes for special tasks. I want to satisfy a grate condition which is all child processes should exit if the main java process ended or exited. I used this code in my java program:

processBuilder = new ProcessBuilder(command);
processBuilder.redirectErrorStream(true);
process = processBuilder.start();

I see sometimes this won't happen. Sample command to execute may be calling a program or shell file. I used waitFor() but it was not effective. I use Ubuntu 12.04 and java 7.21. Can anybody help me about this?

EDIT: I want the child process be stopped by the OS even if main java process exited unexpectedly.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top