summaryrefslogtreecommitdiff
path: root/mcon/U/d_eofpipe.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/d_eofpipe.U')
-rw-r--r--mcon/U/d_eofpipe.U93
1 files changed, 93 insertions, 0 deletions
diff --git a/mcon/U/d_eofpipe.U b/mcon/U/d_eofpipe.U
new file mode 100644
index 0000000..c516ba3
--- /dev/null
+++ b/mcon/U/d_eofpipe.U
@@ -0,0 +1,93 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?RCS:
+?RCS: $Log: d_eofpipe.U,v $
+?RCS: Revision 3.0.1.1 1994/10/29 16:12:40 ram
+?RCS: patch36: call ./bsd explicitly instead of relying on PATH
+?RCS:
+?RCS: Revision 3.0 1993/08/18 12:05:57 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?RCS:
+?MAKE:d_eofpipe: cat +cc +ccflags +libs rm Oldconfig Guess echo n c
+?MAKE: -pick add $@ %<
+?S:d_eofpipe:
+?S: This variable conditionally defines the EOFPIPE symbol, which
+?S: indicates to the C program that select will correctly detect the EOF
+?S: condition when pipe is closed from the other end.
+?S:.
+?C:EOFPIPE:
+?C: This symbol, if defined, indicates that EOF condition will be detected
+?C: by the reader of the pipe when it is closed by the writing process.
+?C: That is, a select() call on that file descriptor will not block when
+?C: only an EOF remains (typical behaviour for BSD systems).
+?C:.
+?H:#$d_eofpipe EOFPIPE /**/
+?H:.
+?F:!mpipe
+: see if pipe correctly gives the EOF condition
+echo " "
+case "$d_eofpipe" in
+'')
+ echo "Let's see if your pipes return EOF to select() upon closing..." >&4
+ $cat >pipe.c <<'EOP'
+int main()
+{
+ int pd[2];
+ int mask;
+
+ pipe(pd);
+ if (0 == fork()) {
+ close(pd[0]);
+ close(pd[1]);
+ exit(0);
+ }
+
+ close(pd[1]);
+ mask = 1 << pd[0];
+ alarm(2);
+ select(32, &mask, (int *) 0, (int *) 0, (char *) 0);
+ if (0 == read(pd[0], &mask, 1))
+ exit(0);
+
+ exit(1);
+}
+EOP
+ if $cc $ccflags -o pipe pipe.c $libs >/dev/null 2>&1; then
+?X: Use a script to avoid the possible 'alarm call' message
+ echo "./pipe || exit 1" > mpipe
+ chmod +x mpipe
+ ./mpipe >/dev/null 2>&1
+ case $? in
+ 0) d_eofpipe="$define";;
+ *) d_eofpipe="$undef";;
+ esac
+ else
+ echo "(The test program did not compile correctly -- Guessing.)"
+ if ./bsd; then
+ d_eofpipe="$define"
+ else
+ d_eofpipe="$undef"
+ fi
+ fi
+ case "$d_eofpipe" in
+ "$define") echo "Yes, they do.";;
+ *) echo "No, they don't! (sigh)";;
+ esac
+ ;;
+*)
+ $echo $n "Your pipes $c"
+ case "$d_eofpipe" in
+ "$define") echo "allow select() to see EOF upon closing.";;
+ *) echo "won't let select() see EOF on closing.";;
+ esac
+ ;;
+esac
+$rm -f *pipe* core
+