How to get pid of child java processes
Posted on 2006-11-07
I am working on jdk 1.3, sun solaris OS....
I use a shell script (using 'nohup') to fork a Java process, which in turn forks more than 2 java processes. I want to get pids of all newly generated child process.
My application has a behaviour that child processes terminate after completing their jobs...And parent Java process forks the child processes again whenever required...
So, everytime I want fresh pids of the child processes
Note: After executing the shell script (in background), I use to close the terminal window.
Actually I want to kill child processes automatically, if I parent Java process found them hang for some reason. I know that 'Process' class has a functionality to kill the child processes, but I found that many times it gets fail due to unknown reasons. So, I want to kill such child processes using a 'kill -9' command using shell script...