aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-10-22 22:16:17 +0000
committerTed Kremenek <kremenek@apple.com>2009-10-22 22:16:17 +0000
commitb2bdf61b5f71e0971bdaa0e4cff9647031c6d8ee (patch)
tree5464d7786b77e36989d044c380759df0c0ddebb4
parent50e846dbda3390610f7b414dd14000ebb170c737 (diff)
downloadexternal_llvm-b2bdf61b5f71e0971bdaa0e4cff9647031c6d8ee.tar.gz
external_llvm-b2bdf61b5f71e0971bdaa0e4cff9647031c6d8ee.tar.bz2
external_llvm-b2bdf61b5f71e0971bdaa0e4cff9647031c6d8ee.zip
Use 'waitpid' instead of 'wait'. Basing Program::Wait() on 'wait()' prevents it being correct within a multithreaded context.
This address: PR 5277 (Program::Wait is unsafe to call from multiple threads). Note: If waitpid() turns out to be non-portable, we can add more autoconf magic, or look into another solution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84903 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/Unix/Program.inc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index 56dea250a7..c52f3a88c0 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -244,7 +244,7 @@ Program::Wait(unsigned secondsToWait,
int status;
uint64_t pid = reinterpret_cast<uint64_t>(Data_);
pid_t child = static_cast<pid_t>(pid);
- while (wait(&status) != child)
+ while (waitpid(pid, &status, 0) != child)
if (secondsToWait && errno == EINTR) {
// Kill the child.
kill(child, SIGKILL);