1 dnl From Mark D Baushke & Derek Price.
3 dnl See if select() on a /dev/null fd hangs when timeout is NULL.
4 dnl Also check to see that /dev/null is in the readfds set returned.
6 dnl Observed on Solaris 7:
7 dnl If /dev/null is in the readfds set, it will never be marked as
8 dnl ready by the OS. In the case of a /dev/null fd being the only fd
9 dnl in the select set and timeout == NULL, the select will hang.
11 dnl If the test fails, then arrange to use select only via a wrapper
12 dnl function that works around the problem.
14 AC_DEFUN([ccvs_FUNC_SELECT],
16 AC_CHECK_HEADERS([fcntl.h])
17 AC_CACHE_CHECK([whether select hangs on /dev/null fd when timeout is NULL],
18 ccvs_cv_func_select_hang,
19 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
21 #include <sys/select.h>
25 #include <errno.h>]], [[
28 struct timeval timeout;
29 int fd = open ("/dev/null", O_RDONLY);
32 FD_SET (fd, &readfds);
36 while ((numfds = select (fd + 1, &readfds, NULL, NULL, &timeout)) < 0
40 ccvs_cv_func_select_hang=no,
41 ccvs_cv_func_select_hang=yes,
42 dnl When crosscompiling, assume it is broken.
43 ccvs_cv_func_select_hang=yes)
45 if test $ccvs_cv_func_select_hang = yes; then
48 AC_LIBOBJ(sunos57-select)
49 AC_DEFINE(select, rpl_select,
50 [Define to rpl_select if the replacement function should be used.])
54 AC_DEFUN([ccvs_PREREQ_SELECT], [
55 AC_CHECK_HEADERS(fcntl.h unistd.h)])