문제

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.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top