1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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 Licence,
?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 Licence; 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 explicitely 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
|