]> granicus.if.org Git - strace/commitdiff
Fix strace -f -o '|command' hangup
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 7 Dec 2010 12:50:49 +0000 (12:50 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 7 Dec 2010 12:50:49 +0000 (12:50 +0000)
* strace.c (main): Call test_ptrace_setoptions() before parsing
-o option, otherwise a forked command will cause a hangup inside
test_ptrace_setoptions().

strace.c

index fd12b34680a120c2268803c3be00e1d4df42a702..e1ae8f1783a1d9cf82fe918fe3ae5c0893177f18 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -945,6 +945,20 @@ main(int argc, char *argv[])
                run_gid = getgid();
        }
 
+#ifdef LINUX
+       if (followfork) {
+               if (test_ptrace_setoptions() < 0) {
+                       fprintf(stderr,
+                               "Test for options supported by PTRACE_SETOPTIONS "
+                               "failed, giving up using this feature.\n");
+                       ptrace_setoptions = 0;
+               }
+               if (debug)
+                       fprintf(stderr, "ptrace_setoptions = %#x\n",
+                               ptrace_setoptions);
+       }
+#endif
+
        /* Check if they want to redirect the output. */
        if (outfname) {
                /* See if they want to pipe the output. */
@@ -975,20 +989,6 @@ main(int argc, char *argv[])
                qflag = 1;
        }
 
-#ifdef LINUX
-       if (followfork) {
-               if (test_ptrace_setoptions() < 0) {
-                       fprintf(stderr,
-                               "Test for options supported by PTRACE_SETOPTIONS "
-                               "failed, giving up using this feature.\n");
-                       ptrace_setoptions = 0;
-               }
-               if (debug)
-                       fprintf(stderr, "ptrace_setoptions = %#x\n",
-                               ptrace_setoptions);
-       }
-#endif
-
        /* Valid states here:
           optind < argc        pflag_seen      outfname        interactive
           1                    0               0               1