-struct {
- int signal;
- void (*handler)(int, siginfo_t *, void *);
-} sighandlers[] = {
- { SIGHUP, sighup_handler },
- { SIGTERM, sigterm_handler },
- { SIGQUIT, sigquit_handler },
- { SIGSEGV, sigsegv_handler },
- { SIGPIPE, NULL },
- { SIGINT, sigint_handler },
- { SIGUSR1, sigusr1_handler },
- { SIGUSR2, sigusr2_handler },
- { SIGCHLD, NULL },
- { 0, NULL }
-};
-
-void
-setup_signals(void)
-{
- int i;
- struct sigaction act;
-
- sigemptyset(&emptysigset);
- act.sa_handler = NULL;
- act.sa_mask = emptysigset;
- act.sa_flags = SA_SIGINFO;
-
- /* Set a default signal handler for every signal, errors will be
- ignored. */
- for(i = 0; i < NSIG; i++)
- {
- act.sa_sigaction = unexpected_signal_handler;
- sigaction(sighandlers[i].signal, &act, NULL);
- }
-
- /* Then, for each known signal that we want to catch, assign a
- handler to the signal, with error checking this time. */
- for(i = 0; sighandlers[i].signal; i++)
- {
- act.sa_sigaction = sighandlers[i].handler;
- if(sigaction(sighandlers[i].signal, &act, NULL) < 0)
- fprintf(stderr, _("Installing signal handler for signal %d (%s) failed: %m\n"),
- sighandlers[i].signal, strsignal(sighandlers[i].signal));
- }