From: Dmitry V. Levin Date: Fri, 2 Jun 2017 21:49:02 +0000 (+0000) Subject: strace.c: handle PTRACE_EVENT_EXEC like other events X-Git-Tag: v4.18~141 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32cff9dc88ed22dba18a65c55e07384b397c8498;p=strace strace.c: handle PTRACE_EVENT_EXEC like other events There is nothing unusual about PTRACE_EVENT_EXEC that would require a special treatment. * strace.c (next_event): Move PTRACE_EVENT_EXEC handling to the main switch statement. --- diff --git a/strace.c b/strace.c index aa6d5388..6d5c29aa 100644 --- a/strace.c +++ b/strace.c @@ -2311,8 +2311,6 @@ next_event(int *pstatus, siginfo_t *si) int pid; int wait_errno; int status; - unsigned int sig; - unsigned int event; struct tcb *tcp; struct rusage ru; @@ -2382,14 +2380,9 @@ next_event(int *pstatus, siginfo_t *si) clear_regs(); - event = (unsigned int) status >> 16; - /* Set current output file */ current_tcp = tcp; - if (event == PTRACE_EVENT_EXEC) - return TE_STOP_BEFORE_EXECVE; - if (cflag) { tv_sub(&tcp->dtime, &ru.ru_stime, &tcp->stime); tcp->stime = ru.ru_stime; @@ -2411,7 +2404,8 @@ next_event(int *pstatus, siginfo_t *si) if (tcp->flags & TCB_STARTUP) startup_tcb(tcp); - sig = WSTOPSIG(status); + const unsigned int sig = WSTOPSIG(status); + const unsigned int event = (unsigned int) status >> 16; switch (event) { case 0: @@ -2456,6 +2450,8 @@ next_event(int *pstatus, siginfo_t *si) } return TE_RESTART; #endif + case PTRACE_EVENT_EXEC: + return TE_STOP_BEFORE_EXECVE; case PTRACE_EVENT_EXIT: return TE_STOP_BEFORE_EXIT; default: