X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fpselect.m4;h=bf7c6b8e317defa40c504e8be6a2f272b858b3ce;hb=1276a2c5f24c0c932426aca9c899fa524d2443f2;hp=97bf12cd2d60aec5291c9958e4f0786479e399da;hpb=1602f0afed21be664fcf5c42d59db07cc22c56d6;p=gnulib.git diff --git a/m4/pselect.m4 b/m4/pselect.m4 index 97bf12cd2..bf7c6b8e3 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -1,5 +1,5 @@ -# pselect.m4 -dnl Copyright (C) 2011-2012 Free Software Foundation, Inc. +# pselect.m4 serial 2 +dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -23,6 +23,44 @@ AC_DEFUN([gl_FUNC_PSELECT], return !p;]])], [gl_cv_sig_pselect=yes], [gl_cv_sig_pselect=no])]) + + dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds. + AC_CACHE_CHECK([whether pselect detects invalid fds], + [gl_cv_func_pselect_detects_ebadf], + [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#if HAVE_SYS_SELECT_H +# include +#endif +#include +#include +]],[[ + fd_set set; + dup2(0, 16); + FD_ZERO(&set); + FD_SET(16, &set); + close(16); + struct timespec timeout; + timeout.tv_sec = 0; + timeout.tv_nsec = 5000; + return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF; +]])], [gl_cv_func_pselect_detects_ebadf=yes], + [gl_cv_func_pselect_detects_ebadf=no], + [ + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_pselect_detects_ebadf="guessing no" ;; + esac + ]) + ]) + case $gl_cv_func_pselect_detects_ebadf in + *yes) ;; + *) REPLACE_PSELECT=1 ;; + esac fi if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then