From 584fd91d2d294883e6896dbd64a2176528e94581 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Mon, 22 Feb 2021 00:25:17 +0100 Subject: [PATCH 1/2] init: only use pipe2 if availabile, check in configure --- configure.ac | 2 ++ src/shutdown.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c0e3b32e3b..426b184e5d 100644 --- a/configure.ac +++ b/configure.ac @@ -925,6 +925,8 @@ AC_CHECK_DECLS([strnlen]) dnl Check for daemon(3), unrelated to --with-daemon (although used by it) AC_CHECK_DECLS([daemon]) +AC_CHECK_DECLS([pipe2]) + AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,, [#if HAVE_ENDIAN_H #include diff --git a/src/shutdown.cpp b/src/shutdown.cpp index df5f996022..6a73e0b2d8 100644 --- a/src/shutdown.cpp +++ b/src/shutdown.cpp @@ -32,7 +32,7 @@ static int g_shutdown_pipe[2] = {-1, -1}; bool InitShutdownState() { #ifndef WIN32 -#if HAVE_O_CLOEXEC +#if HAVE_O_CLOEXEC && HAVE_DECL_PIPE2 // If we can, make sure that the file descriptors are closed on exec() // to prevent interference. if (pipe2(g_shutdown_pipe, O_CLOEXEC) != 0) { From 9bac71350d98580cc7441957fc7c3fa2f4158553 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sun, 21 Feb 2021 02:56:13 +0100 Subject: [PATCH 2/2] build: make HAVE_O_CLOEXEC available outside LevelDB (bugfix) --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 426b184e5d..ca4ee94843 100644 --- a/configure.ac +++ b/configure.ac @@ -1151,6 +1151,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [ AC_MSG_RESULT(yes); HAVE_O_CLOEXEC=1 ], [ AC_MSG_RESULT(no); HAVE_O_CLOEXEC=0 ] ) +AC_DEFINE_UNQUOTED([HAVE_O_CLOEXEC], [$HAVE_O_CLOEXEC], [Define to 1 if O_CLOEXEC flag is available.]) dnl crc32c platform checks AC_MSG_CHECKING(for __builtin_prefetch)