From: Eugene Syromyatnikov Date: Thu, 21 Feb 2019 11:56:29 +0000 (+0100) Subject: strace.c: pass signal number to cleanup() X-Git-Tag: v5.0~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8d7a451fa115674049a2a76fba839a5464ef5eb2;p=strace strace.c: pass signal number to cleanup() * strace.c (die): Pass 0 as an argument to cleanup(). (cleanup): Add fatal_sig parameter, remove the local variable of the same name, do not use interrupted. (terminate): Initialise a new local variable "sig" with "interrupted", pass it to cleanup() and use it instead of "interrupted" for exit_code initialisation. --- diff --git a/strace.c b/strace.c index 195d2c1b..0a924002 100644 --- a/strace.c +++ b/strace.c @@ -157,7 +157,7 @@ char *program_invocation_name; unsigned os_release; /* generated from uname()'s u.release */ static void detach(struct tcb *tcp); -static void cleanup(void); +static void cleanup(int sig); static void interrupt(int sig); #ifdef HAVE_SIG_ATOMIC_T @@ -309,7 +309,7 @@ void ATTRIBUTE_NORETURN die(void) { if (strace_tracer_pid == getpid()) { - cleanup(); + cleanup(0); exit(1); } @@ -1924,14 +1924,11 @@ pid2tcb(const int pid) } static void -cleanup(void) +cleanup(int fatal_sig) { unsigned int i; struct tcb *tcp; - int fatal_sig; - /* 'interrupted' is a volatile object, fetch it only once */ - fatal_sig = interrupted; if (!fatal_sig) fatal_sig = SIGTERM; @@ -2642,7 +2639,9 @@ extern void __gcov_flush(void); static void ATTRIBUTE_NORETURN terminate(void) { - cleanup(); + int sig = interrupted; + + cleanup(sig); if (cflag) call_summary(shared_log); fflush(NULL); @@ -2652,8 +2651,8 @@ terminate(void) while (waitpid(popen_pid, NULL, 0) < 0 && errno == EINTR) ; } - if (interrupted) { - exit_code = 0x100 | interrupted; + if (sig) { + exit_code = 0x100 | sig; } if (exit_code > 0xff) { /* Avoid potential core file clobbering. */