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
|
?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_pidcheck.U,v $
?RCS: Revision 3.0.1.1 1997/02/28 15:37:55 ram
?RCS: patch61: replaced .o with $_o all over the place
?RCS: patch61: added ?F: metalint hint
?RCS:
?RCS: Revision 3.0 1993/08/18 12:06:46 ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_pidcheck: cat rm +cc _o
?MAKE: -pick add $@ %<
?S:d_pidcheck:
?S: This variable conditionally defines the variable PIDCHECK
?S: which indicates that kill(pid, 0) will check for an active pid.
?S:.
?C:PIDCHECK:
?C: This symbol, if defined, means that the kill(pid, 0) will
?C: check for an active pid (i.e. the kernel will run all the
?C: necessary pid checks, but no signal is actually sent).
?C:.
?H:#$d_pidcheck PIDCHECK /**/
?H:.
?F:!try
: check for "kill(pid, 0)"
echo " "
case "$d_pidcheck" in
"$define")
echo "I already know your system supports kill(pid, 0) for pid checks." >&4
;;
"$undef")
echo "We both know your system does not support signal #0 for pid checks." >&4
;;
*)
echo "Checking to see if kill(pid, 0) works..." >&4
$cat >try.c <<'EOCP'
int main()
{
int pid, status0, status9;
if ((pid = fork()) == 0)
{
sleep(30);
exit(1);
}
status0 = kill(pid, 0);
status9 = kill(pid, 9);
exit(status0 == status9);
}
EOCP
if $cc -o try try.c >/dev/null 2>&1 ; then
if ./try >/dev/null 2>&1 ; then
echo "Yes, it does marvels."
d_pidcheck="$undef"
else
d_pidcheck="$define"
echo "No, it doesn't."
fi
else
echo "(I was unable to compile the test program.)"
echo "Your system does not appear to support kill(pid, 0)."
d_pidcheck="$undef"
fi
$rm -f try.c try$_o try
;;
esac
|