-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));
- }
+#ifdef WEXITSTATUS
+ if(status != -1) {
+ if(WIFEXITED(status)) { /* Child exited by itself */
+ if(WEXITSTATUS(status)) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d",
+ name, WEXITSTATUS(status));
+ return false;
+ }
+ } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */
+ logger(DEBUG_ALWAYS, LOG_ERR, "Script %s was killed by signal %d (%s)",
+ name, WTERMSIG(status), strsignal(WTERMSIG(status)));
+ return false;
+ } else { /* Something strange happened */
+ logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name);
+ return false;
+ }
+ } else {
+ logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno));
+ return false;
+ }
+#endif
+#endif
+ return true;