summaryrefslogtreecommitdiff
path: root/mcon/U/d_wifstat.U
blob: 5bffaa5c07151d933b2e79a5f7602c5ce27e883d (plain)
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
?RCS: $Id: d_wifstat.U 1 2006-08-24 12:32:52Z rmanfredi $
?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_wifstat.U,v $
?RCS: Revision 3.0.1.3  1997/02/28  15:47:43  ram
?RCS: patch61: added a ?F: metalint hint
?RCS:
?RCS: Revision 3.0.1.2  1995/07/25  14:09:10  ram
?RCS: patch56: re-arranged compile line to include ldflags before objects
?RCS:
?RCS: Revision 3.0.1.1  1995/03/21  08:47:46  ram
?RCS: patch52: created
?RCS:
?MAKE:d_wifstat: d_uwait +cc +ccflags +ldflags +libs Oldconfig cat rm
?MAKE:	-pick add $@ %<
?S:d_wifstat:
?S:	This symbol conditionally defines USE_WIFSTAT if the C program can
?S:	safely use the WIFxxx macros with the kind of wait() parameter
?S:	declared in the program (see UNION_WAIT), or if it can't. Should
?S:	only matter on HP-UX, where the macros are incorrectly written and
?S:	therefore cause programs using them with an 'union wait' variable
?S:	to not compile properly.
?S:.
?C:USE_WIFSTAT:
?C:	This symbol, if defined, indicates to the C program that the argument
?C:	for the WIFxxx set of macros such as WIFSIGNALED or WIFEXITED can
?C:	be of the same kind as the one used to hold the wait() status. Should
?C:	only matter on HP-UX, where the macros are incorrectly written and
?C:	therefore cause programs using them with an 'union wait' variable
?C:	to not compile properly. See also UNION_WAIT.
?C:.
?H:#$d_wifstat USE_WIFSTAT		/**/
?H:.
?T:type
?F:!foo
: see if we can use WIFxxx macros
echo " "
case "$d_wifstat" in
"$define") echo "As before, you can safely use WIFEXITED and friends!" >&4;;
"$undef") echo "You still can't use WIFEXITED and friends!" >&4;;
*)
	echo "Let's see whether you can use the WIFEXITED(status) macro and its"
	case "$d_uwait" in
	"$define") type='union wait';;
	*) type='int';;
	esac
	echo "friends with status declared as '$type status'..."
	$cat >foo.c <<EOCP
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
	$type status;
	int e = 0;

#ifdef WIFEXITED
	if (WIFEXITED(status))
		printf("\n");
	exit(0);
#else
	exit(2);
#endif
}
EOCP
	d_wifstat="$undef"
	if $cc $ccflags $ldflags -o foo foo.c $libs >/dev/null 2>&1; then
		if ./foo >/dev/null; then
			echo "Great! Looks like we can use the WIFxxx macros." >&4
			d_wifstat="$define"
		else
			echo "You don't seem to have WIFxxx macros, but that's ok." >&4
		fi
	else
		echo "Apparently you can't use WIFxxx macros properly." >&4
	fi
	$rm -f foo.* foo core
	;;
esac