diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -340,10 +340,12 @@ 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 ::waitpid; +#else +using ::wait4; #endif } // namespace sys @@ -414,12 +416,18 @@ // Parent process: Wait for the child process to terminate. int status = 0; ProcessInfo WaitResult; +#ifndef __Fuchsia__ rusage Info; if (ProcStat) ProcStat->reset(); +#endif do { +#ifndef __Fuchsia__ WaitResult.Pid = sys::wait4(ChildPid, &status, WaitPidOptions, &Info); +#else + WaitResult.Pid = sys::waitpid(ChildPid, &status, WaitPidOptions); +#endif } while (WaitUntilTerminates && WaitResult.Pid == -1 && errno == EINTR); if (WaitResult.Pid != PI.Pid) { @@ -459,6 +467,7 @@ 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 +477,7 @@ #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.