1 # Test whether a file descriptor is a pipe.
3 dnl Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 dnl Written by Paul Eggert.
11 AC_DEFUN([gl_ISAPIPE],
13 # OpenVMS has isapipe already, so check for it.
14 AC_REPLACE_FUNCS([isapipe])
15 if test $ac_cv_func_isapipe = no; then
20 # Prerequisites of lib/isapipe.c.
21 AC_DEFUN([gl_PREREQ_ISAPIPE],
23 AC_CACHE_CHECK([whether pipes are FIFOs (and for their link count)],
24 [gl_cv_pipes_are_fifos],
28 #include <sys/types.h>
38 main (int argc, char **argv)
44 if (fstat (fd[0], &st) != 0)
46 if (2 <= argc && argv[1][0] == '-')
48 char const *yesno = (S_ISFIFO (st.st_mode) ? "yes" : "no");
51 long int i = st.st_nlink;
54 printf ("%s (%ld)\n", yesno, i);
58 unsigned long int i = st.st_nlink;
61 printf ("%s (%lu)\n", yesno, i);
66 if (! S_ISFIFO (st.st_mode) && ! S_ISSOCK (st.st_mode))
71 [gl_cv_pipes_are_fifos=`./conftest$ac_exeext -`
72 test -z "$gl_cv_pipes_are_fifos" && gl_cv_pipes_are_fifos=no],
73 [gl_cv_pipes_are_fifos=unknown],
74 [gl_cv_pipes_are_fifos=cross-compiling])])
76 case $gl_cv_pipes_are_fifos in #(
78 AC_DEFINE([HAVE_FIFO_PIPES], [1],
79 [Define to 1 if pipes are FIFOs, 0 if sockets. Leave undefined
82 AC_DEFINE([HAVE_FIFO_PIPES], [0]);;
85 case $gl_cv_pipes_are_fifos in #(
87 AC_DEFINE_UNQUOTED([PIPE_LINK_COUNT_MAX],
88 [`expr "$gl_cv_pipes_are_fifos" : '.*\((.*)\)'`],
89 [Define to the maximum link count that a true pipe can have.]);;