]> granicus.if.org Git - strace/commitdiff
2007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
authorRoland McGrath <roland@redhat.com>
Sat, 3 Nov 2007 23:34:11 +0000 (23:34 +0000)
committerRoland McGrath <roland@redhat.com>
Sat, 3 Nov 2007 23:34:11 +0000 (23:34 +0000)
* strace.c (main): Move the STARTUP_CHILD call before setting up the
signal handlers.  New comment about the valid internal states.

strace.c

index 9d82f586eaccd34c328d872795253170114845da..b71e093b83621ee0e384c4ffbddbf92e3effdfa7 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -817,6 +817,20 @@ main(int argc, char *argv[])
                interactive = 0;
                qflag = 1;
        }
+       /* Valid states here:
+          optind < argc        pflag_seen      outfname        interactive
+          1                    0               0               1
+          0                    1               0               1
+          1                    0               1               0
+          0                    1               1               1
+        */
+
+       /* STARTUP_CHILD must be called before the signal handlers get
+          installed below as they are inherited into the spawned process.
+          Also we do not need to be protected by them as during interruption
+          in the STARTUP_CHILD mode we kill the spawned process anyway.  */
+       if (!pflag_seen)
+               startup_child(&argv[optind]);
 
        sigemptyset(&empty_set);
        sigemptyset(&blocked_set);
@@ -857,8 +871,6 @@ main(int argc, char *argv[])
 
        if (pflag_seen)
                startup_attach();
-       else
-               startup_child(&argv[optind]);
 
        if (trace() < 0)
                exit(1);