configure.ac: Check that we can use O_CLOEXEC with pipe2().

Needed for EL5.

Based on:
https://github.com/rurban/mosh/commit/c70c3707e65b42ac9b9da937e9c255211330805e
This commit is contained in:
Keegan McAllister
2012-04-13 21:29:49 -04:00
committed by Keith Winstein
parent 99e8626a01
commit 85d197346a
2 changed files with 12 additions and 7 deletions
+11 -6
View File
@@ -243,6 +243,17 @@ if test -z "$poll_LIBS"; then
AC_CHECK_LIB([poll], [poll], [poll_LIBS="-lpoll"])
fi
AC_MSG_CHECKING([whether pipe2(..., O_CLOEXEC) is supported])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
int pipefd[2];
]], [[(void) pipe2(pipefd, O_CLOEXEC);]])],
[AC_DEFINE([HAVE_PIPE2_CLOEXEC], [1],
[Define if pipe2(..., O_CLOEXEC) is available.])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_CHECK_DECLS([__builtin_bswap64, __builtin_ctz])
AC_CHECK_DECL([mach_absolute_time],
@@ -250,12 +261,6 @@ AC_CHECK_DECL([mach_absolute_time],
[Define if mach_absolute_time is available.])],
, [[#include <mach/mach_time.h>]])
AC_CHECK_DECL([pipe2],
[AC_DEFINE([HAVE_PIPE2], [1],
[Define if pipe2 is available.])],
, [[#define _GNU_SOURCE
#include <unistd.h>]])
AC_CHECK_DECL([forkpty],
[AC_DEFINE([FORKPTY_IN_LIBUTIL], [1],
[Define if libutil.h necessary for forkpty().])],
+1 -1
View File
@@ -3,7 +3,7 @@
#include "config.h"
#ifdef HAVE_PIPE2
#ifdef HAVE_PIPE2_CLOEXEC
#define HASPIPE2
#else
#undef HASPIPE2