[libc-commits] [PATCH] D76267: [libc] Resolve race condition in sub-process test runner.
Paula Toth via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Mar 17 12:57:22 PDT 2020
PaulkaToast updated this revision to Diff 250872.
PaulkaToast added a comment.
Add comment explaining why we wait on pid.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76267/new/
https://reviews.llvm.org/D76267
Files:
libc/utils/testutils/ExecuteFunctionUnix.cpp
Index: libc/utils/testutils/ExecuteFunctionUnix.cpp
===================================================================
--- libc/utils/testutils/ExecuteFunctionUnix.cpp
+++ libc/utils/testutils/ExecuteFunctionUnix.cpp
@@ -67,8 +67,12 @@
}
int WStatus = 0;
- int status = ::waitpid(Pid, &WStatus, WNOHANG);
- assert(status == Pid && "wait call should not block here");
+ // Wait on the pid of the subprocess here so it gets collected by the system
+ // and doesn't turn into a zombie.
+ pid_t status = ::waitpid(Pid, &WStatus, 0);
+ if (status == -1)
+ return ProcessStatus::Error("waitpid(2) failed");
+ assert(status == Pid);
(void)status;
return {WStatus};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76267.250872.patch
Type: text/x-patch
Size: 686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200317/6f82850e/attachment.bin>
More information about the libc-commits
mailing list