[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 13:30:15 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG17566573b299: [libc] Resolve race condition in sub-process test runner. (authored by PaulkaToast).

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.250888.patch
Type: text/x-patch
Size: 686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200317/007f4261/attachment.bin>


More information about the libc-commits mailing list