[PATCH] D155793: [Support] Avoid wait4 on Fuchsia
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 00:51:26 PDT 2023
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: abrachet, hiraditya.
Herald added a project: All.
phosek requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fuchsia doesn't provide wait4, use waitpid instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155793
Files:
llvm/lib/Support/Unix/Program.inc
Index: llvm/lib/Support/Unix/Program.inc
===================================================================
--- llvm/lib/Support/Unix/Program.inc
+++ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155793.542344.patch
Type: text/x-patch
Size: 1485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230720/9a2f9ef2/attachment.bin>
More information about the llvm-commits
mailing list