+#ifdef HAVE_SYSTEM
+ pid_t pid;
+ int status;
+ struct stat s;
+ char *scriptname;
+
+ cp();
+
+ asprintf(&scriptname, "\"%s/%s\"", confbase, name);
+
+#ifndef HAVE_MINGW
+ /* First check if there is a script */
+
+ if(stat(scriptname, &s))
+ return true;
+
+ ifdebug(STATUS) logger(LOG_INFO, _("Executing script %s"), name);
+#endif
+
+#ifdef HAVE_PUTENV
+ /* Set environment */
+
+ while(*envp)
+ putenv(*envp++);
+#endif
+
+ status = system(scriptname);
+
+ free(scriptname);
+
+ /* Unset environment? */
+
+#ifdef WEXITSTATUS
+ if(status != -1) {
+ if(WIFEXITED(status)) { /* Child exited by itself */
+ if(WEXITSTATUS(status)) {
+ logger(LOG_ERR, _("Process %d (%s) exited with non-zero status %d"),
+ pid, name, WEXITSTATUS(status));
+ return false;
+ }
+ } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */
+ logger(LOG_ERR, _("Process %d (%s) was killed by signal %d (%s)"), pid,
+ name, WTERMSIG(status), strsignal(WTERMSIG(status)));
+ return false;
+ } else { /* Something strange happened */
+ logger(LOG_ERR, _("Process %d (%s) terminated abnormally"), pid,
+ name);
+ return false;
+ }
+ } else {
+ logger(LOG_ERR, _("System call `%s' failed: %s"), "system",
+ strerror(errno));
+ return false;
+ }
+#endif
+#endif
+ return true;