1 ?RCS: $Id: sig_name.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: $Log: sig_name.U,v $
12 ?RCS: Revision 3.0.1.5 1997/02/28 16:21:25 ram
13 ?RCS: patch61: brand new algorithm for sig_name and (new!) sig_num
15 ?RCS: Revision 3.0.1.4 1995/07/25 14:14:54 ram
16 ?RCS: patch56: added <asm/signal.h> lookup for Linux
18 ?RCS: Revision 3.0.1.3 1995/05/12 12:24:11 ram
19 ?RCS: patch54: now looks for <linux/signal.h> too (ADO)
21 ?RCS: Revision 3.0.1.2 1994/06/20 07:06:57 ram
22 ?RCS: patch30: final echo was missing to close awk-printed string
24 ?RCS: Revision 3.0.1.1 1994/05/06 15:17:55 ram
25 ?RCS: patch23: signal list now formatted to avoid scroll-ups (ADO)
27 ?RCS: Revision 3.0 1993/08/18 12:09:47 ram
28 ?RCS: Baseline for dist 3.0 netwide release.
30 ?MAKE:sig_name sig_name_init sig_num sig_num_init sig_count sig_size: \
31 awk Signal Oldconfig rm
32 ?MAKE: -pick add $@ %<
34 ?S: This variable holds the signal names, space separated. The leading
35 ?S: SIG in signal name is removed. A ZERO is prepended to the list.
36 ?S: This is currently not used, sig_name_init is used instead.
39 ?S: This variable holds the signal names, enclosed in double quotes and
40 ?S: separated by commas, suitable for use in the SIG_NAME definition
41 ?S: below. A "ZERO" is prepended to the list, and the list is
42 ?S: terminated with a plain 0. The leading SIG in signal names
43 ?S: is removed. See sig_num.
46 ?S: This variable holds the signal numbers, space separated. A ZERO is
47 ?S: prepended to the list (corresponding to the fake SIGZERO).
48 ?S: Those numbers correspond to the value of the signal listed
49 ?S: in the same place within the sig_name list.
50 ?S: This is currently not used, sig_num_init is used instead.
53 ?S: This variable holds the signal numbers, enclosed in double quotes and
54 ?S: separated by commas, suitable for use in the SIG_NUM definition
55 ?S: below. A "ZERO" is prepended to the list, and the list is
56 ?S: terminated with a plain 0.
58 ?S:sig_count (sig_name.U):
59 ?S: This variable holds a number larger than the largest valid
60 ?S: signal number. This is usually the same as the NSIG macro.
63 ?S: This variable contains the number of elements of the sig_name
64 ?S: and sig_num arrays.
67 ?C: This symbol contains a list of signal names in order of
68 ?C: signal number. This is intended
69 ?C: to be used as a static array initialization, like this:
70 ?C: char *sig_name[] = { SIG_NAME };
71 ?C: The signals in the list are separated with commas, and each signal
72 ?C: is surrounded by double quotes. There is no leading SIG in the signal
73 ?C: name, i.e. SIGQUIT is known as "QUIT".
74 ?C: Gaps in the signal numbers (up to NSIG) are filled in with NUMnn,
75 ?C: etc., where nn is the actual signal number (e.g. NUM37).
76 ?C: The signal number for sig_name[i] is stored in sig_num[i].
77 ?C: The last element is 0 to terminate the list with a NULL. This
78 ?C: corresponds to the 0 at the end of the sig_name_init list.
79 ?C: Note that this variable is initialized from the sig_name_init,
80 ?C: not from sig_name (which is unused).
83 ?C: This symbol contains a list of signal numbers, in the same order as the
84 ?C: SIG_NAME list. It is suitable for static array initialization, as in:
85 ?C: int sig_num[] = { SIG_NUM };
86 ?C: The signals in the list are separated with commas, and the indices
87 ?C: within that list and the SIG_NAME list match, so it's easy to compute
88 ?C: the signal name from a number or vice versa at the price of a small
89 ?C: dynamic linear lookup.
90 ?C: Duplicates are allowed, but are moved to the end of the list.
91 ?C: The signal number corresponding to sig_name[i] is sig_number[i].
92 ?C: if (i < NSIG) then sig_number[i] == i.
93 ?C: The last element is 0, corresponding to the 0 at the end of
94 ?C: the sig_name_init list.
95 ?C: Note that this variable is initialized from the sig_num_init,
96 ?C: not from sig_num (which is unused).
99 ?C: This variable contains a number larger than the largest
100 ?C: signal number. This is usually the same as the NSIG macro.
103 ?C: This variable contains the number of elements of the SIG_NAME
104 ?C: and SIG_NUM arrays, excluding the final NULL entry.
106 ?H:#define SIG_NAME $sig_name_init /**/
107 ?H:#define SIG_NUM $sig_num_init /**/
108 ?H:#define SIG_COUNT $sig_count /**/
109 ?H:#define SIG_SIZE $sig_size /**/
113 ?X: signal.cmd creates a file signal.lst which has two columns:
114 ?X: NAME number, e.g.
116 ?X: The list is sorted on signal number, with duplicates moved to
118 : generate list of signal names
120 case "$sig_name_init" in
122 *) case "$sig_num_init" in
123 ''|*,*) doinit=yes ;;
128 echo "Generating a list of signal names and numbers..." >&4
130 sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
131 sig_name=`$awk 'BEGIN { printf "ZERO " }
132 !/^NSIG/ { printf "%s ", $1 }' signal.lst`
133 sig_num=`$awk 'BEGIN { printf "0 " }
134 !/^NSIG/ { printf "%d ", $2 }' signal.lst`
135 sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
136 !/^NSIG/ { printf "\"%s\", ", $1 }
137 END { printf "0\n" }' signal.lst`
138 sig_num_init=`$awk 'BEGIN { printf "0, " }
139 !/^NSIG/ { printf "%d, ", $2}
140 END { printf "0\n"}' signal.lst`
143 echo "The following $sig_count signals are available:"
145 echo $sig_name | $awk \
146 'BEGIN { linelen = 0 }
148 for (i = 1; i <= NF; i++) {
150 linelen = linelen + length(name)
153 linelen = length(name)
159 sig_size=`echo $sig_name | awk '{print NF}'`
160 $rm -f signal signal.c signal.awk signal.lst signal_cmd