This is an archive of the discontinued LLVM Phabricator instance.

Add wait for child process(s) to exit.
ClosedPublic

Authored by rsundahl on Jun 24 2022, 4:40 PM.

Details

Summary

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

Diff Detail

Event Timeline

rsundahl created this revision.Jun 24 2022, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 4:40 PM
Herald added a subscriber: Enna1. · View Herald Transcript
rsundahl requested review of this revision.Jun 24 2022, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 4:40 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
rsundahl retitled this revision from Add wait for child processe(s) to exit. to Add wait for child process(s) to exit..Jun 24 2022, 4:49 PM
yln added a comment.Jun 24 2022, 5:29 PM

Thanks, I like this attempt to make the test less flaky!

Note that on Linux the compilation of the test file now fails:

/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp:37:11: error: use of undeclared identifier 'wait'
    while(wait(NULL) > 0);

Is there a common header we can include?

yln added a comment.Jun 24 2022, 5:31 PM

I think it's: #include <sys/wait.h>

rsundahl updated this revision to Diff 439949.Jun 24 2022, 8:44 PM

Adding include of <sys/wait.h> for Linux.

I think it's: #include <sys/wait.h>

...and I knew better! Thanks for catching this.

rsundahl updated this revision to Diff 440013.Jun 25 2022, 4:00 PM

Applied clang-format

yln accepted this revision.Jun 27 2022, 9:22 AM
This revision is now accepted and ready to land.Jun 27 2022, 9:22 AM