]> granicus.if.org Git - strace/commitdiff
Close pipe and wait for the pipe process termination
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 12 Jul 2012 20:54:46 +0000 (20:54 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 12 Jul 2012 20:54:46 +0000 (20:54 +0000)
In case of normal strace termination, when the trace output is
redirected to a file or a pipe, close it and wait for the pipe
process termination.

* strace.c (main): Before normal exit, close shared_log when it
differs from stderr, and wait for popen_pid termination.

strace.c

index e6d6d687f64a3a965e98387841655796a6ecb6be..799fce517c612b34c33eef0958b32272f5c7806e 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2214,6 +2214,12 @@ main(int argc, char *argv[])
 
        cleanup();
        fflush(NULL);
+       if (shared_log != stderr)
+               fclose(shared_log);
+       if (popen_pid) {
+               while (waitpid(popen_pid, NULL, 0) < 0 && errno == EINTR)
+                       ;
+       }
        if (exit_code > 0xff) {
                /* Avoid potential core file clobbering.  */
                struct rlimit rlim = {0, 0};