summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/mainloop.c
diff options
context:
space:
mode:
authorMartin Hunt <hunt@redhat.com>2008-05-05 14:22:16 -0400
committerMartin Hunt <hunt@redhat.com>2008-05-05 14:22:16 -0400
commit3c3355335d4e1f4a195999e784cd88118ca955d8 (patch)
tree616167a5c94bc8061171ebfc21a3982acba90238 /runtime/staprun/mainloop.c
parent25acff96f6a1398300a08051f329ac76a46207f2 (diff)
downloadsystemtap-steved-3c3355335d4e1f4a195999e784cd88118ca955d8.tar.gz
systemtap-steved-3c3355335d4e1f4a195999e784cd88118ca955d8.tar.xz
systemtap-steved-3c3355335d4e1f4a195999e784cd88118ca955d8.zip
Fix problem handling SIG_CHLD
Diffstat (limited to 'runtime/staprun/mainloop.c')
-rw-r--r--runtime/staprun/mainloop.c16
1 files changed, 14 insertions, 2 deletions
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);