From: JF Bastien Date: Wed, 24 Apr 2019 23:24:53 +0000 (+0000) Subject: posix_spawn should retry upon EINTR X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7574f40240386bc51ba5ff3a6f0d7818812a2613;p=llvm 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. Reviewers: Bigcheese, arphaman Subscribers: jkorous, dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61096 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359152 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc index dce592f5923..c4123a64046 100644 --- a/lib/Support/Unix/Program.inc +++ b/lib/Support/Unix/Program.inc @@ -245,12 +245,16 @@ static bool Execute(ProcessInfo &PI, StringRef Program, Envp = const_cast(*_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(Argv), - const_cast(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(Argv), + const_cast(Envp)); + } while (Err == EINTR && ++retries < maxRetries); if (FileActions) posix_spawn_file_actions_destroy(FileActions);