diff options
author | Petr Hosek <phosek@google.com> | 2023-07-20 07:49:27 +0000 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2023-08-23 23:32:44 +0000 |
commit | 7038bed9161b8993d61d9623f0d55cfbdfea41a0 (patch) | |
tree | bf5c58418217ff9d9516adf6b1c477c88eb7a425 /llvm/lib/Support/Unix/Program.inc | |
parent | e954085f80d2146e7bbb8e3c50f8bfa455eb4e32 (diff) | |
download | llvm-7038bed9161b8993d61d9623f0d55cfbdfea41a0.zip llvm-7038bed9161b8993d61d9623f0d55cfbdfea41a0.tar.gz llvm-7038bed9161b8993d61d9623f0d55cfbdfea41a0.tar.bz2 |
[Support] Avoid wait4 on Fuchsia
Fuchsia doesn't provide wait4, use waitpid instead.
Differential Revision: https://reviews.llvm.org/D155793
Diffstat (limited to 'llvm/lib/Support/Unix/Program.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index 897e227..9466d0f 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -340,10 +340,10 @@ static bool Execute(ProcessInfo &PI, StringRef Program, namespace llvm { namespace sys { -#ifndef _AIX -using ::wait4; -#else +#if defined(_AIX) static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage); +#elif !defined(__Fuchsia__) +using ::wait4; #endif } // namespace sys @@ -414,6 +414,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, // Parent process: Wait for the child process to terminate. int status = 0; ProcessInfo WaitResult; +#ifndef __Fuchsia__ rusage Info; if (ProcStat) ProcStat->reset(); @@ -421,6 +422,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, do { WaitResult.Pid = sys::wait4(ChildPid, &status, WaitPidOptions, &Info); } while (WaitUntilTerminates && WaitResult.Pid == -1 && errno == EINTR); +#endif if (WaitResult.Pid != PI.Pid) { if (WaitResult.Pid == 0) { @@ -459,6 +461,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, sigaction(SIGALRM, &Old, nullptr); } +#ifndef __Fuchsia__ if (ProcStat) { std::chrono::microseconds UserT = toDuration(Info.ru_utime); std::chrono::microseconds KernelT = toDuration(Info.ru_stime); @@ -468,6 +471,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, #endif *ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory}; } +#endif // Return the proper exit status. Detect error conditions // so we can return -1 for them and set ErrMsg informatively. |