Modernize the initalization of sigproptbl.
Use C99 designators to set the value of each slot and the nitems macro to check for valid entries. In the process, switch to indexing by signal number rather than signal-1 for improved clarity.
This commit is contained in:
parent
0feb2d6270
commit
a6053c5abf
@ -201,42 +201,43 @@ SYSCTL_INT(_kern, OID_AUTO, coredump_devctl, CTLFLAG_RW, &coredump_devctl,
|
||||
* Signal properties and actions.
|
||||
* The array below categorizes the signals and their default actions.
|
||||
*/
|
||||
static int sigproptbl[NSIG] = {
|
||||
SIGPROP_KILL, /* SIGHUP */
|
||||
SIGPROP_KILL, /* SIGINT */
|
||||
SIGPROP_KILL|SIGPROP_CORE, /* SIGQUIT */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGILL */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGTRAP */
|
||||
SIGPROP_KILL|SIGPROP_CORE, /* SIGABRT */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGEMT */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGFPE */
|
||||
SIGPROP_KILL, /* SIGKILL */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGBUS */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGSEGV */
|
||||
SIGPROP_KILL|SIGPROP_CORE, /* SIGSYS */
|
||||
SIGPROP_KILL, /* SIGPIPE */
|
||||
SIGPROP_KILL, /* SIGALRM */
|
||||
SIGPROP_KILL, /* SIGTERM */
|
||||
SIGPROP_IGNORE, /* SIGURG */
|
||||
SIGPROP_STOP, /* SIGSTOP */
|
||||
SIGPROP_STOP|SIGPROP_TTYSTOP, /* SIGTSTP */
|
||||
SIGPROP_IGNORE|SIGPROP_CONT, /* SIGCONT */
|
||||
SIGPROP_IGNORE, /* SIGCHLD */
|
||||
SIGPROP_STOP|SIGPROP_TTYSTOP, /* SIGTTIN */
|
||||
SIGPROP_STOP|SIGPROP_TTYSTOP, /* SIGTTOU */
|
||||
SIGPROP_IGNORE, /* SIGIO */
|
||||
SIGPROP_KILL, /* SIGXCPU */
|
||||
SIGPROP_KILL, /* SIGXFSZ */
|
||||
SIGPROP_KILL, /* SIGVTALRM */
|
||||
SIGPROP_KILL, /* SIGPROF */
|
||||
SIGPROP_IGNORE, /* SIGWINCH */
|
||||
SIGPROP_IGNORE, /* SIGINFO */
|
||||
SIGPROP_KILL, /* SIGUSR1 */
|
||||
SIGPROP_KILL, /* SIGUSR2 */
|
||||
SIGPROP_KILL, /* SIGTHR */
|
||||
SIGPROP_KILL, /* SIGLIBRT */
|
||||
SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND, /* SIGPROT */
|
||||
static int sigproptbl[] = {
|
||||
[SIGHUP] = SIGPROP_KILL,
|
||||
[SIGINT] = SIGPROP_KILL,
|
||||
[SIGQUIT] = SIGPROP_KILL|SIGPROP_CORE,
|
||||
[SIGILL] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGTRAP] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGABRT] = SIGPROP_KILL|SIGPROP_CORE,
|
||||
[SIGEMT] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGFPE] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGKILL] = SIGPROP_KILL,
|
||||
[SIGBUS] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGSEGV] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
[SIGSYS] = SIGPROP_KILL|SIGPROP_CORE,
|
||||
[SIGPIPE] = SIGPROP_KILL,
|
||||
[SIGALRM] = SIGPROP_KILL,
|
||||
[SIGTERM] = SIGPROP_KILL,
|
||||
[SIGURG] = SIGPROP_IGNORE,
|
||||
[SIGSTOP] = SIGPROP_STOP,
|
||||
[SIGTSTP] = SIGPROP_STOP|SIGPROP_TTYSTOP,
|
||||
[SIGCONT] = SIGPROP_IGNORE|SIGPROP_CONT,
|
||||
[SIGCHLD] = SIGPROP_IGNORE,
|
||||
[SIGTTIN] = SIGPROP_STOP|SIGPROP_TTYSTOP,
|
||||
[SIGTTOU] = SIGPROP_STOP|SIGPROP_TTYSTOP,
|
||||
[SIGIO] = SIGPROP_IGNORE,
|
||||
[SIGXCPU] = SIGPROP_KILL,
|
||||
[SIGXFSZ] = SIGPROP_KILL,
|
||||
[SIGVTALRM] = SIGPROP_KILL,
|
||||
[SIGPROF] = SIGPROP_KILL,
|
||||
[SIGWINCH] = SIGPROP_IGNORE,
|
||||
[SIGINFO] = SIGPROP_IGNORE,
|
||||
[SIGUSR1] = SIGPROP_KILL,
|
||||
[SIGUSR2] = SIGPROP_KILL,
|
||||
[SIGTHR] = SIGPROP_KILL,
|
||||
[SIGLIBRT] = SIGPROP_KILL,
|
||||
[SIGPROT] = SIGPROP_KILL|SIGPROP_CORE|SIGPROP_SBUNWIND,
|
||||
};
|
||||
static size_t sigproptbl_count = nitems(sigproptbl);
|
||||
|
||||
static void reschedule_signals(struct proc *p, sigset_t block, int flags);
|
||||
|
||||
@ -618,8 +619,8 @@ int
|
||||
sigprop(int sig)
|
||||
{
|
||||
|
||||
if (sig > 0 && sig < NSIG)
|
||||
return (sigproptbl[_SIG_IDX(sig)]);
|
||||
if (sig > 0 && sig < sigproptbl_count)
|
||||
return (sigproptbl[sig]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user