aboue Runtime.getRuntime().exec() create process

haifeng zhou

Greenhorn

Posts: 13

posted 8 years ago

it run in Unix
Runtime.getRuntime().exec() will create child process to excute shell script
and if I kill parent process, the child process will aslo exit
so, does any way to prevent child process exit???

However, this probably won't work if you kill the entire parent JVM, since that would kill all child threads. To avoid that, you'd probably need to launch a new OS process, not a new JVM process. These are some Unix system calls for that kind of stuff, but I'm not sure if pure Java can use them (I'm too lazy to RTFM). If not, however, you could always create a new shell process with a shell script that does it.