diff options
author | JF Bastien <jfbastien@apple.com> | 2019-04-24 23:24:53 +0000 |
---|---|---|
committer | JF Bastien <jfbastien@apple.com> | 2019-04-24 23:24:53 +0000 |
commit | fb742da34c1393550daf6073374051b16cea6686 (patch) | |
tree | 1e18728973764bbfa3e4f724c313df4dbd66eb8a /llvm/lib/Support/Unix/Program.inc | |
parent | 54763e44532feb72bf773260b377f2a0bacf0e0c (diff) | |
download | bcm5719-llvm-fb742da34c1393550daf6073374051b16cea6686.tar.gz bcm5719-llvm-fb742da34c1393550daf6073374051b16cea6686.zip |
posix_spawn should retry upon EINTR
Summary:
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>
Reviewers: Bigcheese, arphaman
Subscribers: jkorous, dexonsmith, kristina, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61096
llvm-svn: 359152
Diffstat (limited to 'llvm/lib/Support/Unix/Program.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index dce592f5923..c4123a64046 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -245,12 +245,16 @@ static bool Execute(ProcessInfo &PI, StringRef Program, 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); |