+/*
+ Execute the given script.
+ This function doesn't really belong here.
+*/
+int execute_script(const char *name)
+{
+ pid_t pid;
+
+ if((pid = fork()) < 0)
+ {
+ syslog(LOG_ERR, _("System call `%s' failed: %m"),
+ "fork");
+ return -1;
+ }
+
+ if(pid)
+ {
+ list_append(child_pids, pid);
+ return 0;
+ }
+
+ /* Child here */
+
+ _execute_script(name);
+}
+
+int check_child(void *data)
+{
+ pid_t pid;
+ int status;
+
+ pid = (pid_t) data;
+ pid = waitpid(pid, &status, WNOHANG);
+ if(WIFEXITED(status))
+ {
+ if(WIFSIGNALED(status)) /* Child was killed by a signal */
+ {
+ syslog(LOG_ERR, _("Child with PID %d was killed by signal %d (%s)"),
+ pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
+ return -1;
+ }
+ if(WEXITSTATUS(status) != 0)
+ {
+ syslog(LOG_INFO, _("Child with PID %d exited with code %d"),
+ WEXITSTATUS(status));
+ }
+ return -1;
+ }
+}
+
+void check_children(void)
+{
+ list_forall_nodes(child_pids, check_child);
+}
+