Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 153 lines (135 sloc) 4.755 kb
a792d68 First commit
Kevin Lipe authored
1 #! /bin/sh
2 # mksignal -- generate es's internal signal table from signal.h ($Revision: 1.1.1.1 $)
3
4 echo '#include "es.h"'
5 echo '#include "sigmsgs.h"'
6 echo
7 echo 'const Sigmsgs signals[] = {'
8
9 sed -n '
10 s/^[ ]*\#[ ]*define[ ]*_*SIG/SIG/
11 s/\/\*[ ]*//
12 s/[ ]*\*\///
13 s/([@*+!]) //
14 s/[ ]*(.*)$//
15 s/[ ]*signal$//
16 /^SIG[A-Z][A-Z0-9]*[ ]/p
17
18 ' $* | awk '
19 BEGIN {
20 nsig = 0
21
22 # set mesg["SIGNAME"] to override a message. since the
23 # comments in /usr/include/sys/signal.h are awful, we
24 # now provide messages for most signals
25
26 mesg["SIGABRT"] = "abort"
27 mesg["SIGALRM"] = "alarm clock"
28 mesg["SIGBUS"] = "bus error"
29 mesg["SIGCHLD"] = "child stopped or exited"
30 mesg["SIGCLD"] = "child stopped or exited"
31 mesg["SIGCONT"] = "continue"
32 mesg["SIGEMT"] = "EMT instruction"
33 mesg["SIGFPE"] = "floating point exception"
34 mesg["SIGHUP"] = "hangup"
35 mesg["SIGILL"] = "illegal instruction"
36 mesg["SIGINFO"] = "information request"
37 mesg["SIGIO"] = "input/output possible"
38 mesg["SIGIOT"] = "IOT instruction"
39 mesg["SIGKILL"] = "killed"
40 mesg["SIGLOST"] = "resource lost"
41 mesg["SIGLWP"] = "lightweight process library signal"
42 mesg["SIGMIGRATE"] = "migrate process"
43 mesg["SIGPOLL"] = "pollable event occurred"
44 mesg["SIGPROF"] = "profiling timer alarm"
45 mesg["SIGPWR"] = "power failure"
46 mesg["SIGQUIT"] = "quit"
47 mesg["SIGRESERVE"] = "reserved signal"
48 mesg["SIGSEGV"] = "segmentation violation"
49 mesg["SIGSTOP"] = "asynchronous stop"
50 mesg["SIGSYS"] = "bad argument to system call"
51 mesg["SIGTERM"] = "terminated"
52 mesg["SIGTRAP"] = "trace trap"
53 mesg["SIGTSTP"] = "stopped"
54 mesg["SIGTTIN"] = "background tty read"
55 mesg["SIGTTOU"] = "background tty write"
56 mesg["SIGURG"] = "urgent condition on i/o channel"
57 mesg["SIGUSR1"] = "user defined signal 1"
58 mesg["SIGUSR2"] = "user defined signal 2"
59 mesg["SIGVTALRM"] = "virtual timer alarm"
60 mesg["SIGWAITING"] = "all lightweight processes blocked"
61 mesg["SIGWINCH"] = "window size changed"
62 mesg["SIGXCPU"] = "exceeded CPU time limit"
63 mesg["SIGXFSZ"] = "exceeded file size limit"
64
65 # these signals are dubious, but we may as well provide clean messages
66 # for them. most of them occur on only one system, or, more likely,
67 # are duplicates of one of the previous messages.
68
69 mesg["SIGAIO"] = "base lan I/O available"
70 mesg["SIGDANGER"] = "danger - system page space full"
71 mesg["SIGEMSG"] = "process received an emergency message"
72 mesg["SIGGRANT"] = "HFT monitor mode granted"
73 mesg["SIGIOINT"] = "printer to backend error"
74 mesg["SIGMSG"] = "input data is in the HFT ring buffer"
75 mesg["SIGPRE"] = "programming exception"
76 mesg["SIGPTY"] = "pty I/O available"
77 mesg["SIGRETRACT"] = "HFT monitor mode should be relinguished"
78 mesg["SIGSAK"] = "secure attention key"
79 mesg["SIGSOUND"] = "HFT sound control has completed"
80 mesg["SIGSTKFLT"] = "stack fault"
81 mesg["SIGUNUSED"] = "unused signal"
82 mesg["SIGVIRT"] = "virtual time alarm"
83 mesg["SIGWINDOW"] = "window size changed"
84
85
86 # set nomesg["SIGNAME"] to suppress message printing
87
88 nomesg["SIGINT"] = 1
89 nomesg["SIGPIPE"] = 1
90
91
92 # set ignore["SIGNAME"] to explicitly ignore a named signal (usually, this
93 # is just for things that look like signals but really are not)
94
95 ignore["SIGALL"] = 1
96 ignore["SIGARRAYSIZE"] = 1
97 ignore["SIGCATCHALL"] = 1
98 ignore["SIGDEFER"] = 1
99 ignore["SIGDIL"] = 1
100 ignore["SIGHOLD"] = 1
101 ignore["SIGIGNORE"] = 1
102 ignore["SIGMAX"] = 1
103 ignore["SIGPAUSE"] = 1
104 ignore["SIGRELSE"] = 1
105 ignore["SIGRTMAX"] = 1
106 ignore["SIGRTMIN"] = 1
107 ignore["SIGSETS"] = 1
108 ignore["SIGSTKSZ"] = 1
109
110 # upper to lowercase translation table: can someone give me an easier
111 # way to do this that works in ancient versions of awk?
112
113 for (i = 65; i <= 90; i++) # 'A' to 'Z'
114 uppertolower[sprintf("%c", i)] = sprintf("%c", i + 32)
115
116 }
117 sig[$1] == 0 && ignore[$1] == 0 {
118 sig[$1] = ++nsig
119 signame[nsig] = $1
120 if (mesg[$1] == "" && nomesg[$1] == 0) {
121 str = $3
122 for (i = 4; i <= NF; i++)
123 str = str " " $i
124 mesg[$1] = str
125 }
126 # hack to print SIGIOT or SIGILL as "abort" if that is the most common
127 # way of triggering it.
128 if ($1 == "SIGABRT" && $2 ~ /^SIG/)
129 mesg[$2] = mesg[$1]
130 }
131 END {
132 for (i = 1; i <= nsig; i++) {
133 signal = signame[i]
134 # gawk, at very least, provides a tolower function, but this should
135 # be portable. sigh.
136 lcname = ""
137 for (j = 1; j <= length(signal); j++) {
138 c = substr(signal, j, 1)
139 if (uppertolower[c] != "")
140 c = uppertolower[c]
141 lcname = lcname c
142 }
143 print "#ifdef", signal
144 printf "\t{ %s,\t\"%s\",\t\"%s\" },\n", signal, lcname, mesg[signal]
145 print "#endif"
146 }
147 }
148 '
149
150 echo '};'
151 echo
152 echo 'const int nsignals = arraysize(signals);'
Something went wrong with that request. Please try again.