Skip to content

Commit bcce6dd

Browse files
philwocopybara-github
authored andcommitted
Add the TEMP_FAILURE_RETRY macro to linux-sandbox-pid1.cc.
This allows us to build Bazel on Linux systems which use a C standard library that does not include this macro, like Alpine Linux (which uses musl). Fixes #12460. PiperOrigin-RevId: 374873483
1 parent 329b22a commit bcce6dd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/tools/linux-sandbox-pid1.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
#include <linux/fs.h>
5050
#endif
5151

52+
#ifndef TEMP_FAILURE_RETRY
53+
// Some C standard libraries like musl do not define this macro, so we'll
54+
// include our own version for compatibility.
55+
#define TEMP_FAILURE_RETRY(exp) \
56+
({ \
57+
decltype(exp) _rc; \
58+
do { \
59+
_rc = (exp); \
60+
} while (_rc == -1 && errno == EINTR); \
61+
_rc; \
62+
})
63+
#endif // TEMP_FAILURE_RETRY
64+
5265
#include "src/main/tools/linux-sandbox-options.h"
5366
#include "src/main/tools/linux-sandbox.h"
5467
#include "src/main/tools/logging.h"

0 commit comments

Comments
 (0)