Skip to content

Commit

Permalink
Add the TEMP_FAILURE_RETRY macro to linux-sandbox-pid1.cc.
Browse files Browse the repository at this point in the history
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 bazelbuild#12460.

PiperOrigin-RevId: 374873483
  • Loading branch information
philwo authored and copybara-github committed May 20, 2021
1 parent 329b22a commit bcce6dd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/tools/linux-sandbox-pid1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
#include <linux/fs.h>
#endif

#ifndef TEMP_FAILURE_RETRY
// Some C standard libraries like musl do not define this macro, so we'll
// include our own version for compatibility.
#define TEMP_FAILURE_RETRY(exp) \
({ \
decltype(exp) _rc; \
do { \
_rc = (exp); \
} while (_rc == -1 && errno == EINTR); \
_rc; \
})
#endif // TEMP_FAILURE_RETRY

#include "src/main/tools/linux-sandbox-options.h"
#include "src/main/tools/linux-sandbox.h"
#include "src/main/tools/logging.h"
Expand Down

0 comments on commit bcce6dd

Please sign in to comment.