[PATCH] D61096: posix_spawn should retry upon EINTR

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 16:22:52 PDT 2019


This revision was automatically updated to reflect the committed changes.
jfb marked an inline comment as done.
Closed by commit rL359152: posix_spawn should retry upon EINTR (authored by jfb, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61096/new/

https://reviews.llvm.org/D61096

Files:
  llvm/trunk/lib/Support/Unix/Program.inc


Index: llvm/trunk/lib/Support/Unix/Program.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Program.inc
+++ llvm/trunk/lib/Support/Unix/Program.inc
@@ -245,12 +245,16 @@
       Envp = const_cast<const char **>(*_NSGetEnviron());
 #endif
 
-    // Explicitly initialized to prevent what appears to be a valgrind false
-    // positive.
-    pid_t PID = 0;
-    int Err = posix_spawn(&PID, Program.str().c_str(), FileActions,
-                          /*attrp*/ nullptr, const_cast<char **>(Argv),
-                          const_cast<char **>(Envp));
+    constexpr int maxRetries = 8;
+    int retries = 0;
+    pid_t PID;
+    int Err;
+    do {
+      PID = 0; // Make Valgrind happy.
+      Err = posix_spawn(&PID, Program.str().c_str(), FileActions,
+                        /*attrp*/ nullptr, const_cast<char **>(Argv),
+                        const_cast<char **>(Envp));
+    } while (Err == EINTR && ++retries < maxRetries);
 
     if (FileActions)
       posix_spawn_file_actions_destroy(FileActions);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61096.196546.patch
Type: text/x-patch
Size: 1068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/9e3a97dc/attachment.bin>


More information about the llvm-commits mailing list