From: Christophe Blaess <mailist@logilin.fr>
To: xenomai@xenomai.org
Subject: Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai?
Date: Tue, 11 Sep 2012 18:53:34 +0200 [thread overview]
Message-ID: <504F6C8E.8070706@logilin.fr> (raw)
In-Reply-To: <504F6604.2000104@xenomai.org>
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.
next prev parent reply other threads:[~2012-09-11 16:53 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 [this message]
2012-09-11 18:27 ` Soo-Hyun Yoo
2012-09-11 18:31 ` Gilles Chanteperdrix
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=504F6C8E.8070706@logilin.fr \
--to=mailist@logilin.fr \
--cc=xenomai@xenomai.org \
/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.