]> granicus.if.org Git - strace/commitdiff
On Ctrl-C induced detach, send SIGINT to child tracee, not SIGTERM.
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 29 Jan 2012 15:43:51 +0000 (16:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 29 Jan 2012 15:43:51 +0000 (16:43 +0100)
* strace.c (interrupt): Remember signal number.
(cleanup): If we exiting due to signal, send that signal to child tracee.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
strace.c

index 26d7010f1fc1ccd38e56d8182a4a1a2633e6fb10..091114053cd288a746125cfaaeff8ccd4aa5892f 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -149,9 +149,9 @@ static sigset_t empty_set, blocked_set;
 
 #ifdef HAVE_SIG_ATOMIC_T
 static volatile sig_atomic_t interrupted;
-#else /* !HAVE_SIG_ATOMIC_T */
+#else
 static volatile int interrupted;
-#endif /* !HAVE_SIG_ATOMIC_T */
+#endif
 
 #ifdef USE_PROCFS
 
@@ -1939,6 +1939,7 @@ cleanup(void)
 {
        int i;
        struct tcb *tcp;
+       int fatal_sig = interrupted ? interrupted : SIGTERM;
 
        for (i = 0; i < tcbtabsize; i++) {
                tcp = tcbtab[i];
@@ -1956,7 +1957,7 @@ cleanup(void)
                        detach(tcp);
                else {
                        kill(tcp->pid, SIGCONT);
-                       kill(tcp->pid, SIGTERM);
+                       kill(tcp->pid, fatal_sig);
                }
        }
        if (cflag)
@@ -1966,7 +1967,7 @@ cleanup(void)
 static void
 interrupt(int sig)
 {
-       interrupted = 1;
+       interrupted = sig;
 }
 
 #ifndef HAVE_STRERROR