blob: 9902ed85d70824e31517a89bc28d46c5b676f27d (
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
|
#!/bin/sh
# generate rc's internal signal table from signal.h
exec > sigmsgs.c
echo '#include "sigmsgs.h"'
echo
echo 'Sigmsgs signals[] = {'
sed ' s/\/\*[ ]*//
s/[ ]*\*\///
s/([@*+!]) //
s/[ ]*([a-zA-Z,->& ]*)[ ]*//
s/^[ ]*\#[ ]*define/\#define/
s/[ ]*signal$//
s/_SIG/SIG/g' $1 |
awk '
BEGIN {
# assign to nomesg["SIGNAME"] to suppress a long message
nomesg["SIGINT"] = 1
nomesg["SIGPIPE"] = 1
# assign to mesg["SIGNAME"] to override a message
mesg["SIGHUP"] = "hangup"
mesg["SIGKILL"] = "killed"
mesg["SIGQUIT"] = "quit"
mesg["SIGTERM"] = "terminated"
mesg["SIGURG"] = "urgent condition on i/o channel"
mesg["SIGSTOP"] = "stop signal not from tty"
mesg["SIGTSTP"] = "stopped"
mesg["SIGCONT"] = "continue"
mesg["SIGCHLD"] = "child stop or exit"
mesg["SIGTTIN"] = "background tty read"
mesg["SIGTTOU"] = "background tty write"
# assign to ignore["SIGNAME"] to explicitly ignore a named signal
ignore["SIGMAX"] = 1
}
$1 == "#define" && $2 == "NSIG" && $3 ~ /^[0-9]+$/ { nsig = $3 }
$1 == "#define" && $2 ~ /^SIG/ && $3 ~ /^[0-9]+$/ && sig[$3] == "" && ignore[$2] == 0 {
sig[$3] = $2
if ($3 > max)
max = $3
if (mesg[$2] == "" && nomesg[$2] == 0) {
str = $4
for (i = 5; i <= NF; i++)
str = str " " $i
mesg[$2] = str
}
}
END {
if (nsig == 0)
nsig = max + 1
printf " {!!, !!},\n"
for (i = 1; i < nsig; i++) {
if (sig[i] == "")
printf " {!!, !!},\n"
else
printf " {!%s!, !%s!},\n", sig[i], mesg[sig[i]]
}
}
' |
tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!' 'abcdefghijklmnopqrstuvwxyz"'
echo '};'
exec > sigmsgs.h
echo 'typedef struct {'
echo ' char *name, *msg;'
echo '} Sigmsgs;'
echo 'extern Sigmsgs signals[];'
grep '^ ' sigmsgs.c | # the thing in quotes is ^<tab>
awk '
{ sum = sum + 1; }
END { print "#define NUMOFSIGNALS", sum }
'
|