3 dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Test whether a file descriptor is a pipe.
10 dnl Written by Paul Eggert.
12 AC_DEFUN([gl_ISAPIPE],
14 # OpenVMS has isapipe already, so check for it.
15 AC_CHECK_FUNCS([isapipe])
16 if test $ac_cv_func_isapipe = yes; then
23 # Prerequisites of lib/isapipe.c.
24 AC_DEFUN([gl_PREREQ_ISAPIPE],
26 AC_CACHE_CHECK([whether pipes are FIFOs (and for their link count)],
27 [gl_cv_pipes_are_fifos],
31 #include <sys/types.h>
41 main (int argc, char **argv)
47 if (fstat (fd[0], &st) != 0)
49 if (2 <= argc && argv[1][0] == '-')
51 char const *yesno = (S_ISFIFO (st.st_mode) ? "yes" : "no");
54 long int i = st.st_nlink;
57 printf ("%s (%ld)\n", yesno, i);
61 unsigned long int i = st.st_nlink;
64 printf ("%s (%lu)\n", yesno, i);
69 if (! S_ISFIFO (st.st_mode) && ! S_ISSOCK (st.st_mode))
74 [gl_cv_pipes_are_fifos=`./conftest$ac_exeext -`
75 test -z "$gl_cv_pipes_are_fifos" && gl_cv_pipes_are_fifos=no],
76 [gl_cv_pipes_are_fifos=unknown],
77 [gl_cv_pipes_are_fifos=cross-compiling])])
79 case $gl_cv_pipes_are_fifos in #(
81 AC_DEFINE([HAVE_FIFO_PIPES], [1],
82 [Define to 1 if pipes are FIFOs, 0 if sockets. Leave undefined
85 AC_DEFINE([HAVE_FIFO_PIPES], [0]);;
88 case $gl_cv_pipes_are_fifos in #(
90 AC_DEFINE_UNQUOTED([PIPE_LINK_COUNT_MAX],
91 [`expr "$gl_cv_pipes_are_fifos" : '.*\((.*)\)'`],
92 [Define to the maximum link count that a true pipe can have.]);;