signal.c revision 3e14f97f673e8a630f076077de35afdd43dc1587
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1985-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* http://www.opensource.org/licenses/cpl1.0.txt *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Glenn Fowler <gsf@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Phong Vo <kpv@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma prototyped
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Glenn Fowler
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * AT&T Research
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * generate signal features
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include "FEATURE/standards"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define strsignal ______strsignal
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <signal.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#undef strsignal
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstruct _m_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* text;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* name;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int value;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin};
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define elementsof(x) (sizeof(x)/sizeof(x[0]))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstatic struct _m_ map[] =
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGABRT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGABRT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Abort", "ABRT", SIGABRT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGAIO
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGAIO 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Asynchronous I/O", "AIO", SIGAIO,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGALRM
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGALRM 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Alarm call", "ALRM", SIGALRM,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGAPOLLO
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGAPOLLO 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Apollo", "APOLLO", SIGAPOLLO,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGBUS
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGBUS 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Bus error", "BUS", SIGBUS,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGCHLD
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGCHLD 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Child status change", "CHLD", SIGCHLD,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGCLD
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGCLD 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Death of child", "CLD", SIGCLD,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGCONT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGCONT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stopped process continued", "CONT", SIGCONT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGDANGER
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGDANGER 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"System crash soon", "DANGER", SIGDANGER,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGDEBUG
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGDEBUG 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Debug trap", "DEBUG", SIGDEBUG,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGDIL
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGDIL 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"DIL trap", "DIL", SIGDIL,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGEMT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGEMT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"EMT trap", "EMT", SIGEMT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGERR
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGERR 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"ERR trap", "ERR", SIGERR,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGEXIT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGEXIT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Exit", "EXIT", SIGEXIT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGFPE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGFPE 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Floating exception", "FPE", SIGFPE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGFREEZE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGFREEZE 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"CPR freeze", "FREEZE", SIGFREEZE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGHUP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGHUP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Hangup", "HUP", SIGHUP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGILL
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGILL 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Illegal instruction", "ILL", SIGILL,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGINT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGINT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Interrupt", "INT", SIGINT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGIO
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGIO 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"IO possible", "IO", SIGIO,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGIOT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGIOT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"IOT trap", "IOT", SIGIOT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGKILL
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGKILL 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Killed", "KILL", SIGKILL,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGLAB
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGLAB 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Security label changed", "LAB", SIGLAB,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGLOST
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGLOST 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Resources lost", "LOST", SIGLOST,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGLWP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGLWP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Thread event", "LWP", SIGLWP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGMIGRATE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGMIGRATE 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Migrate process", "MIGRATE", SIGMIGRATE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGPHONE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGPHONE 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Phone status change", "PHONE", SIGPHONE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGPIPE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGPIPE 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Broken pipe", "PIPE", SIGPIPE,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGPOLL
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGPOLL 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Poll event", "POLL", SIGPOLL,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGPROF
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGPROF 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Profile timer alarm", "PROF", SIGPROF,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGPWR
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGPWR 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Power fail", "PWR", SIGPWR,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGQUIT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGQUIT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Quit", "QUIT", SIGQUIT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGSEGV
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGSEGV 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Memory fault", "SEGV", SIGSEGV,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGSOUND
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGSOUND 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Sound completed", "SOUND", SIGSOUND,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGSSTOP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGSSTOP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Sendable stop", "SSTOP", SIGSSTOP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef gould
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_gould 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stack overflow", "STKOV", 28,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGSTOP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGSTOP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stopped (signal)", "STOP", SIGSTOP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGSYS
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGSYS 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Bad system call", "SYS", SIGSYS,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTERM
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTERM 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Terminated", "TERM", SIGTERM,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTHAW
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTHAW 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"CPR thaw", "THAW", SIGTHAW,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTINT
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTINT 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Interrupt (terminal)", "TINT", SIGTINT,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTRAP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTRAP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Trace trap", "TRAP", SIGTRAP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTSTP
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTSTP 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stopped", "TSTP", SIGTSTP,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTTIN
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTTIN 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stopped (tty input)", "TTIN", SIGTTIN,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGTTOU
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGTTOU 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Stopped (tty output)", "TTOU", SIGTTOU,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGURG
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGURG 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Urgent IO", "URG", SIGURG,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGUSR1
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGUSR1 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"User signal 1", "USR1", SIGUSR1,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGUSR2
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGUSR2 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"User signal 2", "USR2", SIGUSR2,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGVTALRM
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGVTALRM 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Virtual timer alarm", "VTALRM", SIGVTALRM,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGWAITING
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGWAITING 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"All threads blocked", "WAITING", SIGWAITING,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGWINCH
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGWINCH 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Window change", "WINCH", SIGWINCH,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGWIND
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGWIND 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Window change", "WIND", SIGWIND,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGWINDOW
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGWINDOW 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"Window change", "WINDOW", SIGWINDOW,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGXCPU
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGXCPU 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"CPU time limit", "XCPU", SIGXCPU,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGXFSZ
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#define HAD_SIGXFSZ 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin"File size limit", "XFSZ", SIGXFSZ,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#include "FEATURE/siglist"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin};
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RANGE_MIN (1<<14)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RANGE_MAX (1<<13)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RANGE_RT (1<<12)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RANGE_SIG (~(RANGE_MIN|RANGE_MAX|RANGE_RT))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinstatic int mapindex[1024];
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#if _lib_strsignal
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinextern char* strsignal(int);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinint
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinmain()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int i;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int j;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin register int k;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin int m;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int n;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#if _lib_strsignal
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin char* s;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin k = 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for (i = 0; map[i].name; i++)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if ((j = map[i].value) > 0 && j < elementsof(mapindex) && !mapindex[j])
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (j > k)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin k = j;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mapindex[j] = i;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGRTMIN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin i = SIGRTMIN;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef SIGRTMAX
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin j = SIGRTMAX;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin j = i;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (j >= elementsof(mapindex))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin j = elementsof(mapindex) - 1;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (i <= j && i > 0 && i < elementsof(mapindex) && j > 0 && j < elementsof(mapindex))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (j > k)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin k = j;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mapindex[i] = RANGE_MIN | RANGE_RT;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin n = 1;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin while (++i < j)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mapindex[i] = RANGE_RT | n++;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin mapindex[j] = RANGE_MAX | RANGE_RT | n;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("#pragma prototyped\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("#define SIG_MAX %d\n", k);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("static const char* const sig_name[] =\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("{\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for (i = 0; i <= k; i++)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (!(j = mapindex[i]))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"%d\",\n", i);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin else if (j & RANGE_RT)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (j & RANGE_MIN)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"RTMIN\",\n");
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else if (j & RANGE_MAX)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"RTMAX\",\n");
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin {
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin m = j & RANGE_SIG;
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (m > n / 2)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"RTMAX-%d\",\n", n - m);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"RTMIN+%d\",\n", m);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin }
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin }
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"%s\",\n", map[j].name);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf(" 0\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("};\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("static const char* const sig_text[] =\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("{\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for (i = 0; i <= k; i++)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin if (!(j = mapindex[i]))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"Signal %d\",\n", i);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else if (j & RANGE_RT)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"Realtime priority %d%s\",\n", j & RANGE_SIG, (j & RANGE_MIN) ? " (lo)" : (j & RANGE_MAX) ? " (hi)" : "");
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else if (map[j].text)
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"%s\",\n", map[j].text);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#if _lib_strsignal
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else if (s = strsignal(i))
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"%s\",\n", s);
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#endif
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin else
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin printf(" \"Signal %d\",\n", i);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf(" 0\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin printf("};\n");
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin return 0;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin}