aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paludis/util/process.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/paludis/util/process.cc b/paludis/util/process.cc
index 3b6f4c6be..0174cdb21 100644
--- a/paludis/util/process.cc
+++ b/paludis/util/process.cc
@@ -863,6 +863,21 @@ Process::Process(ProcessCommand && c) :
Process::~Process() = default;
+namespace
+{
+ pid_t
+ waitpid_noeintr(pid_t pid, int *wstatus, int options)
+ {
+ while (true)
+ {
+ pid_t ret = ::waitpid(pid, wstatus, options);
+ if (ret == -1 && errno == EINTR) // waitpid was interrupted by a signal, retry
+ continue;
+ return ret;
+ }
+ }
+}
+
RunningProcessHandle
Process::run()
{
@@ -1202,7 +1217,7 @@ Process::run()
ExecError error(error_pipe.read_fd());
if (error)
{
- if (-1 == ::waitpid(child, nullptr, 0))
+ if (-1 == ::waitpid_noeintr(child, nullptr, 0))
throw ProcessError("waitpid() returned -1");
throw ProcessError(error);
@@ -1440,7 +1455,7 @@ RunningProcessHandle::wait()
int status(0);
if (actually_wait)
- if (-1 == ::waitpid(_imp->pid, &status, 0))
+ if (-1 == ::waitpid_noeintr(_imp->pid, &status, 0))
throw ProcessError("waitpid() returned -1");
_imp->pid = -1;