All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Soo-Hyun Yoo <yoos117@gmail.com>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai?
Date: Tue, 11 Sep 2012 20:31:42 +0200	[thread overview]
Message-ID: <504F838E.9090608@xenomai.org> (raw)
In-Reply-To: <CAP1DbD7vj4zFCZf69pFSBw0Mn_XqXg1r0mD6_UBYiW_jcbiR2Q@mail.gmail.com>

On 09/11/2012 08:27 PM, Soo-Hyun Yoo wrote:

> On Tue, Sep 11, 2012 at 9:53 AM, Christophe Blaess <mailist@logilin.fr> wrote:
>> Le 11/09/2012 18:25, Gilles Chanteperdrix a écrit :
>>
>>> On 09/11/2012 06:22 PM, Soo-Hyun Yoo wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have a certain process "A" that forks and execs a process "B". B
>>>> spawns multiple child processes.
>>>>
>>>> In the vanilla Linux kernel, I can have A send a SIGTERM or SIGKILL to
>>>> B and thereby successfully kill B and all of its children.
>>
>> No, the childs of B remain alive. Try this code.
>>
>> *test-kill.c*
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>>
>> int main(void)
>> {
>>     pid_t pid;
>>
>>     fprintf(stderr, "[%d] I'm A\n", getpid());
>>     if ((pid = fork()) == 0) {
>>         fprintf(stderr, "[%d] I'm B\n", getpid());
>>        if (fork() == 0) {
>>             while (1) {
>>                 fprintf(stderr, "[%d] I'm C\n", getpid());
>>                 sleep(1);
>>             }
>>         } else {
>>             while (1) {
>>                 fprintf(stderr, "[%d] I'm B\n", getpid());
>>                 sleep(1);
>>             }
>>         }
>>     }
>>     sleep(3);
>>     fprintf(stderr,"A kills B\n");
>>     kill(pid, 9);
>>     fprintf(stderr, "and A exits\n");
>>     exit(0);
>> }
>>
>>
>> And you'll see :
>>
>> $ ./test-kill
>> [15925] I'm A
>> [15926] I'm B
>> [15926] I'm B
>> [15927] I'm C
>> [15926] I'm B
>> [15927] I'm C
>> [15926] I'm B
>> [15927] I'm C
>> A kills B
>> and A exits
>> $ [15927] I'm C
>> [15927] I'm C
>> [15927] I'm C
>> [15927] I'm C
>> [15927] I'm C
>> [15927] I'm C
>> [15927] I'm C
>>
>> To kill B's childs, you need to send the signal to the group of processes.
> 
> I see I had misunderstood the way in which processes work. Thank you
> for the code. Apparently, I also did not test this as thoroughly as I
> thought I had.
> 
> What really is a problem is that Robot Operating System's rosbag (our
> process B) does not die properly upon receiving a SIGINT in Xenomai
> (whereas it does in vanilla Linux) and instead gets stuck at 100% CPU
> core usage in a few of its threads. This is what led me to 4 hours of
> fumbling around with other signal types. This, however, is a different
> problem that is probably more related to ROS, so I will ask on their
> mailing list.


If you can connect gdb to the remaining process, debugging this is
should be easy. One difference between Xenomai and plain linux processes
is that Xenomai spawns a thread for handling the printfs from primary
mode, so, you can not exit the main thread with pthread_exit any longer,
you have to exit it with exit.

-- 
                                                                Gilles.



      reply	other threads:[~2012-09-11 18:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 16:22 [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? Soo-Hyun Yoo
2012-09-11 16:25 ` Gilles Chanteperdrix
2012-09-11 16:53   ` Christophe Blaess
2012-09-11 18:27     ` Soo-Hyun Yoo
2012-09-11 18:31       ` Gilles Chanteperdrix [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=504F838E.9090608@xenomai.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    --cc=yoos117@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.