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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
#! /bin/sh
# mksignal -- generate es's internal signal table from signal.h ($Revision: 1.1.1.1 $)
echo '#include "es.h"'
echo '#include "sigmsgs.h"'
echo
echo 'const Sigmsgs signals[] = {'
sed -n '
s/^[ ]*\#[ ]*define[ ]*_*SIG/SIG/
s/\/\*[ ]*//
s/[ ]*\*\///
s/([@*+!]) //
s/[ ]*(.*)$//
s/[ ]*signal$//
/^SIG[A-Z][A-Z0-9]*[ ]/p
' $* | awk '
BEGIN {
nsig = 0
# set mesg["SIGNAME"] to override a message. since the
# comments in /usr/include/sys/signal.h are awful, we
# now provide messages for most signals
mesg["SIGABRT"] = "abort"
mesg["SIGALRM"] = "alarm clock"
mesg["SIGBUS"] = "bus error"
mesg["SIGCHLD"] = "child stopped or exited"
mesg["SIGCLD"] = "child stopped or exited"
mesg["SIGCONT"] = "continue"
mesg["SIGEMT"] = "EMT instruction"
mesg["SIGFPE"] = "floating point exception"
mesg["SIGHUP"] = "hangup"
mesg["SIGILL"] = "illegal instruction"
mesg["SIGINFO"] = "information request"
mesg["SIGIO"] = "input/output possible"
mesg["SIGIOT"] = "IOT instruction"
mesg["SIGKILL"] = "killed"
mesg["SIGLOST"] = "resource lost"
mesg["SIGLWP"] = "lightweight process library signal"
mesg["SIGMIGRATE"] = "migrate process"
mesg["SIGPOLL"] = "pollable event occurred"
mesg["SIGPROF"] = "profiling timer alarm"
mesg["SIGPWR"] = "power failure"
mesg["SIGQUIT"] = "quit"
mesg["SIGRESERVE"] = "reserved signal"
mesg["SIGSEGV"] = "segmentation violation"
mesg["SIGSTOP"] = "asynchronous stop"
mesg["SIGSYS"] = "bad argument to system call"
mesg["SIGTERM"] = "terminated"
mesg["SIGTRAP"] = "trace trap"
mesg["SIGTSTP"] = "stopped"
mesg["SIGTTIN"] = "background tty read"
mesg["SIGTTOU"] = "background tty write"
mesg["SIGURG"] = "urgent condition on i/o channel"
mesg["SIGUSR1"] = "user defined signal 1"
mesg["SIGUSR2"] = "user defined signal 2"
mesg["SIGVTALRM"] = "virtual timer alarm"
mesg["SIGWAITING"] = "all lightweight processes blocked"
mesg["SIGWINCH"] = "window size changed"
mesg["SIGXCPU"] = "exceeded CPU time limit"
mesg["SIGXFSZ"] = "exceeded file size limit"
# these signals are dubious, but we may as well provide clean messages
# for them. most of them occur on only one system, or, more likely,
# are duplicates of one of the previous messages.
mesg["SIGAIO"] = "base lan I/O available"
mesg["SIGDANGER"] = "danger - system page space full"
mesg["SIGEMSG"] = "process received an emergency message"
mesg["SIGGRANT"] = "HFT monitor mode granted"
mesg["SIGIOINT"] = "printer to backend error"
mesg["SIGMSG"] = "input data is in the HFT ring buffer"
mesg["SIGPRE"] = "programming exception"
mesg["SIGPTY"] = "pty I/O available"
mesg["SIGRETRACT"] = "HFT monitor mode should be relinguished"
mesg["SIGSAK"] = "secure attention key"
mesg["SIGSOUND"] = "HFT sound control has completed"
mesg["SIGSTKFLT"] = "stack fault"
mesg["SIGUNUSED"] = "unused signal"
mesg["SIGVIRT"] = "virtual time alarm"
mesg["SIGWINDOW"] = "window size changed"
# set nomesg["SIGNAME"] to suppress message printing
nomesg["SIGINT"] = 1
nomesg["SIGPIPE"] = 1
# set ignore["SIGNAME"] to explicitly ignore a named signal (usually, this
# is just for things that look like signals but really are not)
ignore["SIGALL"] = 1
ignore["SIGARRAYSIZE"] = 1
ignore["SIGCATCHALL"] = 1
ignore["SIGDEFER"] = 1
ignore["SIGDIL"] = 1
ignore["SIGHOLD"] = 1
ignore["SIGIGNORE"] = 1
ignore["SIGMAX"] = 1
ignore["SIGPAUSE"] = 1
ignore["SIGRELSE"] = 1
ignore["SIGRTMAX"] = 1
ignore["SIGRTMIN"] = 1
ignore["SIGSETS"] = 1
ignore["SIGSTKSZ"] = 1
# upper to lowercase translation table: can someone give me an easier
# way to do this that works in ancient versions of awk?
for (i = 65; i <= 90; i++) # 'A' to 'Z'
uppertolower[sprintf("%c", i)] = sprintf("%c", i + 32)
}
sig[$1] == 0 && ignore[$1] == 0 {
sig[$1] = ++nsig
signame[nsig] = $1
if (mesg[$1] == "" && nomesg[$1] == 0) {
str = $3
for (i = 4; i <= NF; i++)
str = str " " $i
mesg[$1] = str
}
# hack to print SIGIOT or SIGILL as "abort" if that is the most common
# way of triggering it.
if ($1 == "SIGABRT" && $2 ~ /^SIG/)
mesg[$2] = mesg[$1]
}
END {
for (i = 1; i <= nsig; i++) {
signal = signame[i]
# gawk, at very least, provides a tolower function, but this should
# be portable. sigh.
lcname = ""
for (j = 1; j <= length(signal); j++) {
c = substr(signal, j, 1)
if (uppertolower[c] != "")
c = uppertolower[c]
lcname = lcname c
}
print "#ifdef", signal
printf "\t{ %s,\t\"%s\",\t\"%s\" },\n", signal, lcname, mesg[signal]
print "#endif"
}
}
'
echo '};'
echo
echo 'const int nsignals = arraysize(signals);'
|