[compiler-rt] d2dad62 - Add wait for child processe(s) to exit. (amended+clang-formatted)

Roy Sundahl via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 13:14:22 PDT 2022


Author: Roy Sundahl
Date: 2022-06-27T13:09:34-07:00
New Revision: d2dad6287cb33d4e2ed226b2bd2e5f9097180200

URL: https://github.com/llvm/llvm-project/commit/d2dad6287cb33d4e2ed226b2bd2e5f9097180200
DIFF: https://github.com/llvm/llvm-project/commit/d2dad6287cb33d4e2ed226b2bd2e5f9097180200.diff

LOG: Add wait for child processe(s) to exit. (amended+clang-formatted)

It was possible for the parent process to exit before the
forked child process had finished. In some shells, this
causes the pipe to close and FileCheck misses some output
from the child. Waiting for the child process to exit before
exiting the parent, assures that all output from stdout and
stderr is combined and forwarded through the pipe to FileCheck.

rdar://95241490

Differential Revision: https://reviews.llvm.org/D128565

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp b/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp
index 680766a8b288..fec9ba081b75 100644
--- a/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp
@@ -12,6 +12,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 __attribute__((noinline))
@@ -32,6 +33,10 @@ int main(int argc, char **argv) {
     fprintf(stderr, "Parent PID: %d\n", getpid());
     foo();
     bar();
+
+    // Wait for the child process(s) to finish
+    while (wait(NULL) > 0)
+      ;
   }
   return 0;
 }


        


More information about the llvm-commits mailing list