akshay_n_s
asked on
How to get pid of child java processes
Hi
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...
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Threads have their limitations, like if any one of them fails then it may cause others to get failed...
That may be true but you can program against that.
;JOOP!
;JOOP!
ASKER
Actually an api that I am using for a CRM software is not thread safe...thats why...
I insist that 'ps' should be spawned to find out the PID of any process.
The processes can be 'identified' by their commandline (using "ps -f" or "ps -ef").
;JOOP!
The processes can be 'identified' by their commandline (using "ps -f" or "ps -ef").
;JOOP!
Java has eased concurrent programming by introducing Threads