]> granicus.if.org Git - strace/commitdiff
Set strace_child only in the right branch
authorDenys Vlasenko <dvlasenk@redhat.com>
Wed, 26 Jun 2013 12:27:11 +0000 (14:27 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Wed, 26 Jun 2013 12:58:03 +0000 (14:58 +0200)
"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 <dvlasenk@redhat.com>
strace.c

index 1415aab31d4a5894c24c8304232e4b2d50d17d6f..4fb1b46e1d48c03bda5413fb5016d89fea4c10f2 100644 (file)
--- 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 {