SIGTERM
Hi,
I want to terminate a parent process that attach several shared
memory segments
with kill(pid, SIGTERM) but it fails to terminate.
Even if I give the command from command line it fails to terminate. If I give kill -9 pid it terminates but the shred memory segments
remains.
Why I cannot terminate it with SIGTERM signal?
"....
status = kill ((pid_t)pid, SIGTERM);
printf("status = %d\n", status);
...."The status is 0. The pid is correct.
TIA,
Bubulac Tatiana.
Quoted 7 lines · Bubulac Tatiana
I want to terminate a parent process that attach several shared
memory segments
withkill(pid, SIGTERM)but it fails to terminate.
Even if I give the command from command line it fails to terminate. If I give kill -9 pid it terminates but the shred memory segments
remains.
Why I cannot terminate it with SIGTERM signal?
Presumably the receiver has either blocked, ignored or caught SIGTERM.
Quoted 5 lines
".... status = kill ((pid_t)pid, SIGTERM); printf("status = %d\n", status); ...."The status is 0. The pid is correct.
That only tells you that the signal was sent. It doesn't tell you what the receiving process did as a result; the receiving process may not have even received the signal by the time that kill() returns.
Signature · 1 line
Glynn Clements <[email protected]>
That's right.
In the parent process I have the line no 6 where it blocks.
...
1 signal (SIGTERM, die);
2 signal (SIGALRM, dummy);
...
3 for (min = 0; min < 15 && not_done; min++)
4 {
5 alarm ((unsigned int) 60); /* wait for 1 minute */ 6 pid = wait (&status); /* Wait for a process to end */ 7 alarm ((unsigned int) 0); /* Reset alarm */
....
8 }
The problem is that the child process did not catch the signal. I put a printf in the child signal handler
function.
If I give the "kill child_pid" also nothing happens. Of course if I give "kill -9 child_pid" the child is killed
and the parent will display "Normal termination".
Quoted 24 lines · Glynn Clements
Quoted 7 lines · Bubulac Tatiana
I want to terminate a parent process that attach several shared
memory segments
withkill(pid, SIGTERM)but it fails to terminate.
Even if I give the command from command line it fails to terminate. If I give kill -9 pid it terminates but the shred memory segments
remains.
Why I cannot terminate it with SIGTERM signal?Presumably the receiver has either blocked, ignored or caught SIGTERM.
Quoted 5 lines
".... status = kill ((pid_t)pid, SIGTERM); printf("status = %d\n", status); ...."The status is 0. The pid is correct.
That only tells you that the signal was sent. It doesn't tell you what the receiving process did as a result; the receiving process may not have even received the signal by the time that
kill()returns.--
Glynn Clements <[email protected]>
Quoted 11 lines · Bubulac Tatiana
In the parent process I have the line no 6 where it blocks.
...
1 signal (SIGTERM, die);
2 signal (SIGALRM, dummy);
...
3 for (min = 0; min < 15 &¬_done; min++)
4 {5 alarm ((unsigned int) 60); /* wait for 1 minute */ 6 pid = wait (&status); /* Wait for a process to end */ 7 alarm ((unsigned int) 0); /* Reset alarm */
Quoted 7 lines
....
8 }The problem is that the child process did not catch the signal. I put a printf in the child signal handler
function.
If I give the "killchild_pid" also nothing happens.
That suggests that the child *is* catching the signal. If the child didn't catch SIGTERM, it would die.
Try changing the child's signal handler to call fflush(), or to use write() instead of printf().
Signature · 1 line
Glynn Clements <[email protected]>