From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <504F6C8E.8070706@logilin.fr> Date: Tue, 11 Sep 2012 18:53:34 +0200 From: Christophe Blaess MIME-Version: 1.0 References: <504F6604.2000104@xenomai.org> In-Reply-To: <504F6604.2000104@xenomai.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org Le 11/09/2012 18:25, Gilles Chanteperdrix a =E9crit : > 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 #include #include int main(void) { pid_t pid; fprintf(stderr, "[%d] I'm A\n", getpid()); if ((pid =3D fork()) =3D=3D 0) { fprintf(stderr, "[%d] I'm B\n", getpid()); if (fork() =3D=3D 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= .