]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle waitpid interruption and add missing string header (#669)
authorGregor Jasny <gjasny@googlemail.com>
Mon, 21 Sep 2020 18:41:30 +0000 (20:41 +0200)
committerGitHub <noreply@github.com>
Mon, 21 Sep 2020 18:41:30 +0000 (20:41 +0200)
src/TemporaryFile.hpp
src/execute.cpp

index 3aae4f90ea655db6e8d566fef930c4acd15cec82..493445bb4adc2171706670163f5a039c2de89bfc 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "third_party/nonstd/string_view.hpp"
 
+#include <string>
+
 // This class represents a unique temporary file created by mkstemp. The file is
 // not deleted by the destructor.
 class TemporaryFile
index c650c8525e7e55be0aa5de5a34feffcb84ae4df8..0d628b7fb934386491025faef71b3afb5b498c5e 100644 (file)
@@ -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));
   }