[PATCH] D61096: posix_spawn should retry upon EINTR
JF Bastien via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 14:59:14 PDT 2019
jfb created this revision.
jfb added reviewers: Bigcheese, arphaman.
Herald added subscribers: llvm-commits, kristina, dexonsmith, jkorous.
Herald added a project: LLVM.
We've seen cases of bots failing with:
clang: error: unable to execute command: posix_spawn failed: Interrupted system call
Add a small retry loop to posix_spawn in case this happens. Don't retry too much in case there's some systemic problem going on, but retry a few times.
rdar://problem/50181448
Repository:
rL LLVM
https://reviews.llvm.org/D61096
Files:
lib/Support/Unix/Program.inc
Index: lib/Support/Unix/Program.inc
===================================================================
--- lib/Support/Unix/Program.inc
+++ 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.196527.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/06bdaf3b/attachment.bin>
More information about the llvm-commits
mailing list