aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Unix/Program.inc
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2022-11-29 14:09:08 -0500
committerMatt Arsenault <Matthew.Arsenault@amd.com>2022-12-22 12:38:59 -0500
commiteb93b8774e2cfc5172f0727db8a50427adcb69d7 (patch)
treea11c9c23bb850b0a37f3009d1d4ee92400b0006b /llvm/lib/Support/Unix/Program.inc
parent5da812461a533b3eaed9af513bc3efff53910ada (diff)
downloadllvm-eb93b8774e2cfc5172f0727db8a50427adcb69d7.zip
llvm-eb93b8774e2cfc5172f0727db8a50427adcb69d7.tar.gz
llvm-eb93b8774e2cfc5172f0727db8a50427adcb69d7.tar.bz2
Support: Add polling option to sys::Wait
Currently the process is terminated after the timeout. Add an option to let the process resume after the timeout instead. https://reviews.llvm.org/D138952
Diffstat (limited to 'llvm/lib/Support/Unix/Program.inc')
-rw-r--r--llvm/lib/Support/Unix/Program.inc8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index adfed22..375102c 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -387,7 +387,8 @@ pid_t(llvm::sys::wait4)(pid_t pid, int *status, int options,
ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
std::optional<unsigned> SecondsToWait,
std::string *ErrMsg,
- std::optional<ProcessStatistics> *ProcStat) {
+ std::optional<ProcessStatistics> *ProcStat,
+ bool Polling) {
struct sigaction Act, Old;
assert(PI.Pid && "invalid pid to wait on, process not started?");
@@ -408,12 +409,11 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
sigemptyset(&Act.sa_mask);
sigaction(SIGALRM, &Act, &Old);
// FIXME The alarm signal may be delivered to another thread.
-
alarm(*SecondsToWait);
}
// Parent process: Wait for the child process to terminate.
- int status;
+ int status = 0;
ProcessInfo WaitResult;
rusage Info;
if (ProcStat)
@@ -428,7 +428,7 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI,
// Non-blocking wait.
return WaitResult;
} else {
- if (SecondsToWait && errno == EINTR) {
+ if (SecondsToWait && errno == EINTR && !Polling) {
// Kill the child.
kill(PI.Pid, SIGKILL);