aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Marc-Antoine Perennou <Marc-Antoine@Perennou.com> 2021-02-05 22:50:23 +0100
committerAvatar Heiko Becker <heirecka@exherbo.org> 2021-06-16 20:46:02 +0000
commit243b1c1c59c08b460342e30f409e18010b421802 (patch)
treeb77cb6a82496b286123ebf20dc1abc312767c73c
parentf3a88e5b2e7f9e4a68325c4766db0790a242e0d0 (diff)
downloadpaludis-243b1c1c59c08b460342e30f409e18010b421802.tar.gz
paludis-243b1c1c59c08b460342e30f409e18010b421802.tar.xz
fix tests for ruby >= 2.6
Somehow with ruby >= 2.6 waitpid sometimes gets interrupted by a signal. Ignoring EINTR and reissuing waitpid fixes the issue. Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
-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;