+ do {
+ rc = waitpid(c,&rv,0);
+ } while(rc < 0 && errno == EINTR);
+ if (rc < 0)
+ fatal_perror("sys_cmd: waitpid for %s", path);
+ if (rc != c) /* OS has gone mad */
+ fatal("sys_cmd: waitpid for %s returned wrong process ID!",
+ path);
+ if (rv) {
+ /* If the command failed reporting its exit status */
+ if (WIFEXITED(rv))
+ Message(M_ERR, "sys_cmd(%s,%s,...) exited with status %d\n",
+ path, arg, WEXITSTATUS(rv));
+ else if(WIFSIGNALED(rv))
+ Message(M_ERR, "sys_cmd(%s,%s,...) exited with signal %d (%s)%s\n",
+ path, arg, WTERMSIG(rv), strsignal(WTERMSIG(rv)),
+ WCOREDUMP(rv) ? " - core dumped" : "");
+ else
+ Message(M_ERR, "sys_cmd(%s,%s,...) exited with wstat %#x",
+ path, arg, rv);
+ }