From 51d40e88c7593d701ba61090608aecdc9e751a9d Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Mon, 21 Sep 2020 20:41:30 +0200 Subject: [PATCH] Handle waitpid interruption and add missing string header (#669) --- src/TemporaryFile.hpp | 2 ++ src/execute.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/TemporaryFile.hpp b/src/TemporaryFile.hpp index 3aae4f90e..493445bb4 100644 --- a/src/TemporaryFile.hpp +++ b/src/TemporaryFile.hpp @@ -22,6 +22,8 @@ #include "third_party/nonstd/string_view.hpp" +#include + // This class represents a unique temporary file created by mkstemp. The file is // not deleted by the destructor. class TemporaryFile diff --git a/src/execute.cpp b/src/execute.cpp index c650c8525..0d628b7fb 100644 --- a/src/execute.cpp +++ b/src/execute.cpp @@ -182,7 +182,12 @@ execute(const char* const* argv, Fd&& fd_out, Fd&& fd_err, pid_t* pid) fd_err.close(); int status; - if (waitpid(*pid, &status, 0) != *pid) { + int result; + + while ((result = waitpid(*pid, &status, 0)) != *pid) { + if (result == -1 && errno == EINTR) { + continue; + } throw Fatal("waitpid failed: {}", strerror(errno)); } -- 2.47.3