diff options
-rw-r--r-- | runtime/staprun/ChangeLog | 5 | ||||
-rw-r--r-- | runtime/staprun/mainloop.c | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog index 65159898..14dac37d 100644 --- a/runtime/staprun/ChangeLog +++ b/runtime/staprun/ChangeLog @@ -1,5 +1,10 @@ 2008-05-05 Martin Hunt <hunt@redhat.com> + * mainloop.c (child_proc): Handle sig_chld + in the proper thread. + +2008-05-05 Martin Hunt <hunt@redhat.com> + * mainloop.c (signal_thread): New thread to handle signals better. (setup_main_signals): Create signal thread. diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c index 21502ea2..de4479dd 100644 --- a/runtime/staprun/mainloop.c +++ b/runtime/staprun/mainloop.c @@ -68,6 +68,17 @@ static void *signal_thread(void *arg) return NULL; } +static void chld_proc(int signum) +{ + int32_t rc, btype = STP_EXIT; + dbug(2, "chld_proc %d (%s)\n", signum, strsignal(signum)); + pid_t pid = waitpid(-1, NULL, WNOHANG); + if (pid != target_pid) + return; + // send STP_EXIT + rc = write(control_channel, &btype, sizeof(btype)); +} + static void setup_main_signals(void) { pthread_t tid; @@ -82,14 +93,15 @@ static void setup_main_signals(void) memset(&sa, 0, sizeof(sa)); sigfillset(&sa.sa_mask); sa.sa_handler = SIG_IGN; - sigaction(SIGCHLD, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); + sa.sa_handler = chld_proc; + sigaction(SIGCHLD, &sa, NULL); + sigemptyset(s); - sigaddset(s, SIGCHLD); sigaddset(s, SIGINT); sigaddset(s, SIGTERM); sigaddset(s, SIGHUP); |