[llvm] 7038bed - [Support] Avoid wait4 on Fuchsia
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 16:33:19 PDT 2023
Author: Petr Hosek
Date: 2023-08-23T23:32:44Z
New Revision: 7038bed9161b8993d61d9623f0d55cfbdfea41a0
URL: https://github.com/llvm/llvm-project/commit/7038bed9161b8993d61d9623f0d55cfbdfea41a0
DIFF: https://github.com/llvm/llvm-project/commit/7038bed9161b8993d61d9623f0d55cfbdfea41a0.diff
LOG: [Support] Avoid wait4 on Fuchsia
Fuchsia doesn't provide wait4, use waitpid instead.
Differential Revision: https://reviews.llvm.org/D155793
Added:
Modified:
llvm/lib/Support/Unix/Program.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 897e22711ae2b1..9466d0f0ba859e 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.
More information about the llvm-commits
mailing list