When I kill parent process, child isn't killed
I written a C program that forks and execs a shell script. The shell script then invokes the JVM to execute a Java program. This all works ok.
My C program (the parent) gets the pid of the shell script (the child) as the return value from the fork call. When I try to kill the script and the jvm by sending the SIGTERM signal to the child process, the child process (the script) dies, but the JVM continues to run. I use kill(child_pid, SIGTERM) in my C code, where child_pid was returned to my by fork, as mentioned above.
When I do a ps from the command prompt, I can see the script and JVM processes. When I check the status of these processes in /proc, the JVM is indeed a child of the script process.
Is it because my script process does not propagate the SIGTERM signal to its child (the JVM)?
Do I need to do something more to my script to propagate this signal?
Here is my script (note cvm is the jvm on my system, I use J2ME, MyProg is my Java program):
#!/bin/sh
/usr/local/java/bin/cvm MyProg
Thanks,
Tim
|