]> granicus.if.org Git - strace/commitdiff
If -o|logger is in use, exit trace loop if nprocs == 0.
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 8 Jul 2013 11:55:04 +0000 (13:55 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 8 Jul 2013 11:55:04 +0000 (13:55 +0200)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
strace.c

index abaa463b21434dd8529f134f23f949f27084b7fb..42cfcb99c546d290a83474ae01dc79b21b9ae48f 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -1973,6 +1973,10 @@ trace(void)
         *  19923 exit_group(1)     = ?
         *  19923 +++ exited with 1 +++
         * Waiting for ECHILD works better.
+        * (However, if -o|logger is in use, we can't do that.
+        * Can work around that by double-forking the logger,
+        * but that loses the ability to wait for its completion on exit.
+        * Oh well...)
         */
        while (1) {
                int pid;
@@ -1985,6 +1989,9 @@ trace(void)
                if (interrupted)
                        return;
 
+               if (popen_pid != 0 && nprocs == 0)
+                       return;
+
                if (interactive)
                        sigprocmask(SIG_SETMASK, &empty_set, NULL);
                pid = wait4(-1, &status, __WALL, (cflag ? &ru : NULL));
@@ -2343,7 +2350,7 @@ trace(void)
                        exit_code = 1;
                        return;
                }
-       } /* while (nprocs != 0) */
+       } /* while (1) */
 }
 
 int