+
+ if(pid) {
+ logger(DEBUG_STATUS, LOG_INFO, _("Executing script %s"), name);
+
+ free(scriptname);
+
+ if(waitpid(pid, &status, 0) == pid) {
+ if(WIFEXITED(status)) { /* Child exited by itself */
+ if(WEXITSTATUS(status)) {
+ logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) exited with non-zero status %d"),
+ pid, name, WEXITSTATUS(status));
+ return -1;
+ } else
+ return 0;
+ } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */
+ logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) was killed by signal %d (%s)"), pid,
+ name, WTERMSIG(status), strsignal(WTERMSIG(status)));
+ return -1;
+ } else { /* Something strange happened */
+ logger(DEBUG_ALWAYS, LOG_ERR, _("Process %d (%s) terminated abnormally"), pid,
+ name);
+ return -1;
+ }
+ } else if (errno != EINTR) {
+ logger(DEBUG_ALWAYS, LOG_ERR, _("System call `%s' failed: %s"), "waitpid",
+ strerror(errno));
+ return -1;
+ }
+
+ /* Why do we get EINTR? */
+ return 0;