When the process stared by strace exits/terminates, forget its pid
The process stared by strace can exit/terminate only once. When this
happens, forget its pid, so that any other event or action related to a
process with the same pid as the pid of that first process would not be
confused with that first process.
* strace.c (print_signalled, print_exited): Clear strace_child when it
equals to the given pid.
diff --git a/strace.c b/strace.c
index 1eaa2b9..9383625 100644
--- a/strace.c
+++ b/strace.c
@@ -2162,8 +2162,10 @@
static void
print_signalled(struct tcb *tcp, const int pid, const int status)
{
- if (pid == strace_child)
+ if (pid == strace_child) {
exit_code = 0x100 | WTERMSIG(status);
+ strace_child = 0;
+ }
if (cflag != CFLAG_ONLY_STATS
&& (qual_flags[WTERMSIG(status)] & QUAL_SIGNAL)
@@ -2184,8 +2186,10 @@
static void
print_exited(struct tcb *tcp, const int pid, const int status)
{
- if (pid == strace_child)
+ if (pid == strace_child) {
exit_code = WEXITSTATUS(status);
+ strace_child = 0;
+ }
if (cflag != CFLAG_ONLY_STATS &&
qflag < 2) {