linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* SIGTERM
@ 2002-05-21 10:51 Bubulac Tatiana
  2002-05-21 14:25 ` SIGTERM Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Bubulac Tatiana @ 2002-05-21 10:51 UTC (permalink / raw)
  To: linux-c-programming

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGTERM
  2002-05-21 10:51 SIGTERM Bubulac Tatiana
@ 2002-05-21 14:25 ` Glynn Clements
  2002-05-22  6:20   ` SIGTERM Bubulac Tatiana
  0 siblings, 1 reply; 4+ messages in thread
From: Glynn Clements @ 2002-05-21 14:25 UTC (permalink / raw)
  To: Bubulac Tatiana; +Cc: linux-c-programming


Bubulac Tatiana wrote:

>     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?

Presumably the receiver has either blocked, ignored or caught SIGTERM.

>     "....
>     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 <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGTERM
  2002-05-21 14:25 ` SIGTERM Glynn Clements
@ 2002-05-22  6:20   ` Bubulac Tatiana
  2002-05-22 14:18     ` SIGTERM Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Bubulac Tatiana @ 2002-05-22  6:20 UTC (permalink / raw)
  To: Glynn Clements; +Cc: linux-c-programming

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".


Glynn Clements wrote:

> Bubulac Tatiana wrote:
>
> >     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?
>
> Presumably the receiver has either blocked, ignored or caught SIGTERM.
>
> >     "....
> >     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 <glynn.clements@virgin.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: SIGTERM
  2002-05-22  6:20   ` SIGTERM Bubulac Tatiana
@ 2002-05-22 14:18     ` Glynn Clements
  0 siblings, 0 replies; 4+ messages in thread
From: Glynn Clements @ 2002-05-22 14:18 UTC (permalink / raw)
  To: Bubulac Tatiana; +Cc: linux-c-programming


Bubulac Tatiana wrote:

> 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.

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().

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-22 14:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-21 10:51 SIGTERM Bubulac Tatiana
2002-05-21 14:25 ` SIGTERM Glynn Clements
2002-05-22  6:20   ` SIGTERM Bubulac Tatiana
2002-05-22 14:18     ` SIGTERM Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).