The result of the O_CLOEXEC availability check is currently only set in the Makefile and passed to LevelDB (see LEVELDB_CPPFLAGS_INT
in src/Makefile.leveldb.include
), but not defined to be used in our codebase. This means that code within the preprocessor conditional #if HAVE_O_CLOEXEC
was actually never compiled. On the master branch this is currently used for pipe creation in src/shutdown.cpp
, PR #21007 moves this part to a new module (I found the issue while testing that PR).
The fix is similar to the one in #19803, which solved the same problem for HAVE_FDATASYNC.
In the course of working on the PR it turned out that pipe2 is not available an all platforms, hence a configure check and a corresponding define HAVE_PIPE2 is introduced and used.
The PR can be tested by anyone with a system that has pipe2 and O_CLOEXEC available by putting gibberish into the HAVE_O_CLOEXEC block: on master, everything should compile fine, on PR, the compiler should abort with an error. At least that’s my naive way of testing preprocessor logic, happy to hear more sophisticated ways :-)