From 7c41ce287804f5409400c2b87bf11ebc6f6e1091 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 8 Jul 2013 13:55:04 +0200 Subject: [PATCH] If -o|logger is in use, exit trace loop if nprocs == 0. Signed-off-by: Denys Vlasenko --- strace.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/strace.c b/strace.c index abaa463b..42cfcb99 100644 --- 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 -- 2.40.0