From b574c7b95a7af0ab9d3dea67685b1f40354f6277 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 21 Aug 2007 16:28:43 +0000 Subject: [PATCH] 2007-08-21 Martin Hunt * mainloop.c (start_cmd): Send SIGINT to target_cmd, not stapio. --- runtime/staprun/ChangeLog | 5 +++++ runtime/staprun/mainloop.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog index 771e375d0..a7b0e87b3 100644 --- a/runtime/staprun/ChangeLog +++ b/runtime/staprun/ChangeLog @@ -1,3 +1,8 @@ +2007-08-21 Martin Hunt + + * mainloop.c (start_cmd): Send SIGINT to target_cmd, + not stapio. + 2007-08-20 David Smith From Lai Jiangshan diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c index 4acfb0017..5072182e1 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; } -- 2.43.5