summaryrefslogtreecommitdiff
path: root/U/sig_name.U
blob: 9b3f9e3440c1ac03aba677145c9b29b8cf486f8c (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
?RCS: $Id: sig_name.U,v 3.0 1993/08/18 12:09:47 ram Exp $
?RCS:
?RCS: Copyright (c) 1991-1993, 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 3.0.
?RCS:
?RCS: $Log: sig_name.U,v $
?RCS: Revision 3.0  1993/08/18  12:09:47  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:sig_name: awk rm Findhdr
?MAKE:	-pick add $@ %<
?S:sig_name:
?S:	This variable holds the signal names, space separated. The leading
?S:	SIG in signals name is removed.
?S:.
?C:SIG_NAME:
?C:	This symbol contains a list of signal names in order. This is intended
?C:	to be used as a static array initialization, like this:
?C:		char *sig_name[] = { SIG_NAME };
?C:	The signals in the list are separated with commas, and each signal
?C:	is surrounded by double quotes. There is no leading SIG in the signal
?C:	name, i.e. SIGQUIT is known as "QUIT".
?C:.
?H:#define SIG_NAME "`echo $sig_name | sed 's/ /","/g'`"	/**/
?H:.
?T:xxx
: generate list of signal names
echo " "
case "$sig_name" in
'')
	echo "Generating a list of signal names..." >&4
	xxx=`./findhdr signal.h`" "`./findhdr sys/signal.h`
	set X `cat $xxx 2>&1 | $awk '
$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $3 ~ /^[1-9][0-9]*$/ {
	sig[$3] = substr($2,4,20)
	if (max < $3 && $3 < 60) {
		max = $3
	}
}

END {
	for (i = 1; i <= max; i++) {
		if (sig[i] == "")
			printf "%d", i
		else
			printf "%s", sig[i]
		if (i < max)
			printf " "
	}
	printf "\n"
}
'`
	shift
	case $# in
	0)
		echo 'kill -l' >/tmp/foo$$
		set X `csh -f </tmp/foo$$`
		$rm -f /tmp/foo$$
		shift
		case $# in
		0)set HUP INT QUIT ILL TRAP IOT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM
		;;
		esac
		;;
	esac
	sig_name="ZERO $*"
	;;
esac
echo "The following signals are available:"
echo $sig_name | 
    $awk 'BEGIN { linelen = 0 }
	 { for (i = 1; i < NF; i++)
	   {
	      name = "SIG" $i " "
	      linelen = linelen + length(name)
	      if (linelen > 70)
		{
		  printf "\n"
		  linelen = length(name)
		}
	      printf "%s", name } }'