* [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? @ 2012-09-11 16:22 Soo-Hyun Yoo 2012-09-11 16:25 ` Gilles Chanteperdrix 0 siblings, 1 reply; 5+ messages in thread From: Soo-Hyun Yoo @ 2012-09-11 16:22 UTC (permalink / raw) To: xenomai 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. Under Xenomai, however, I am noticing that the same action kills B, but B's children make init their new parent and continue running. Why is this, and what can I do to kill B's children without having to use a script to track down each child process individually? Thank you. Soo-Hyun Yoo Dynamic Robotics Laboratory Oregon State University ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? 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 0 siblings, 1 reply; 5+ messages in thread From: Gilles Chanteperdrix @ 2012-09-11 16:25 UTC (permalink / raw) To: Soo-Hyun Yoo; +Cc: xenomai 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. > > Under Xenomai, however, I am noticing that the same action kills B, > but B's children make init their new parent and continue running. > > Why is this, and what can I do to kill B's children without having to > use a script to track down each child process individually? No idea, please send a test case allowing us to reproduce the issue. -- Gilles. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? 2012-09-11 16:25 ` Gilles Chanteperdrix @ 2012-09-11 16:53 ` Christophe Blaess 2012-09-11 18:27 ` Soo-Hyun Yoo 0 siblings, 1 reply; 5+ messages in thread From: Christophe Blaess @ 2012-09-11 16:53 UTC (permalink / raw) To: xenomai 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? 2012-09-11 16:53 ` Christophe Blaess @ 2012-09-11 18:27 ` Soo-Hyun Yoo 2012-09-11 18:31 ` Gilles Chanteperdrix 0 siblings, 1 reply; 5+ messages in thread From: Soo-Hyun Yoo @ 2012-09-11 18:27 UTC (permalink / raw) To: Christophe Blaess; +Cc: xenomai 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. Soo-Hyun Yoo > > > _______________________________________________ > Xenomai mailing list > Xenomai@xenomai.org > http://www.xenomai.org/mailman/listinfo/xenomai ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Xenomai] Children of forked process do not die upon receiving SIGKILL in Xenomai? 2012-09-11 18:27 ` Soo-Hyun Yoo @ 2012-09-11 18:31 ` Gilles Chanteperdrix 0 siblings, 0 replies; 5+ messages in thread From: Gilles Chanteperdrix @ 2012-09-11 18:31 UTC (permalink / raw) To: Soo-Hyun Yoo; +Cc: xenomai 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-11 18:31 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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.