From b574c7b95a7af0ab9d3dea67685b1f40354f6277 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 21 Aug 2007 16:28:43 +0000 Subject: 2007-08-21 Martin Hunt * mainloop.c (start_cmd): Send SIGINT to target_cmd, not stapio. --- runtime/staprun/mainloop.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'runtime/staprun/mainloop.c') diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c index 4acfb001..5072182e 100644 --- a/runtime/staprun/mainloop.c +++ b/runtime/staprun/mainloop.c @@ -27,8 +27,7 @@ static void sigproc(int signum) return; send_request(STP_EXIT, NULL, 0); } else if (signum == SIGQUIT) - cleanup_and_exit(2); - + cleanup_and_exit(2); else if (signum == SIGINT || signum == SIGHUP || signum == SIGTERM) send_request(STP_EXIT, NULL, 0); } @@ -63,11 +62,19 @@ void start_cmd(void) { pid_t pid; sigset_t usrset; - + struct sigaction a; + sigemptyset(&usrset); sigaddset(&usrset, SIGUSR1); pthread_sigmask(SIG_BLOCK, &usrset, NULL); + /* if we are execing a target cmd, ignore ^C in stapio */ + /* and let the target cmd get it. */ + sigemptyset(&a.sa_mask); + a.sa_flags = 0; + a.sa_handler = SIG_IGN; + sigaction(SIGINT, &a, NULL); + dbug (1, "execing target_cmd %s\n", target_cmd); if ((pid = fork()) < 0) { _perr("fork"); @@ -75,6 +82,9 @@ void start_cmd(void) } else if (pid == 0) { int signum; + a.sa_handler = SIG_DFL; + sigaction(SIGINT, &a, NULL); + /* wait here until signaled */ sigwait(&usrset, &signum); @@ -213,6 +223,7 @@ int init_stapio(void) if (target_cmd) start_cmd(); + return 0; } -- cgit