From: Denys Vlasenko Date: Wed, 26 Jun 2013 12:27:11 +0000 (+0200) Subject: Set strace_child only in the right branch X-Git-Tag: v4.9~224 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8681c926c02dad48aca66f3aba1e33122002c36;p=strace Set strace_child only in the right branch "strace_child = pid" assignment was racing in NOMMU case because of vfork (no way to know which process would win). After this change, strace_child is set to nonzero only in one process after [v]fork. Signed-off-by: Denys Vlasenko --- diff --git a/strace.c b/strace.c index 1415aab3..4fb1b46e 100644 --- a/strace.c +++ b/strace.c @@ -1204,7 +1204,7 @@ startup_child(char **argv) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); #endif - strace_child = pid = fork(); + pid = fork(); if (pid < 0) { perror_msg_and_die("fork"); } @@ -1221,6 +1221,7 @@ startup_child(char **argv) /* We are the tracer */ if (!daemonized_tracer) { + strace_child = pid; if (!use_seize) { /* child did PTRACE_TRACEME, nothing to do in parent */ } else {