Replace two open-coded exit status checks with calls to lg_exitstatus.
In the case of slip.c and udp.c this has no significant effect other
than a slight change to message format.
In the case of process.c, we no longer log the command's first
argument. I consider this tolerable for simplifying the code.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
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\n",
- path, arg, rv);
+ /* If the command failed report its exit status */
+ lg_exitstatus(0,"sys_cmd",0,M_ERR,rv,path);
}
} else if (c==0) {
char *args[100];
return;
}
if (!st->expecting_userv_exit) {
- if (WIFEXITED(status)) {
- fatal("%s: userv exited unexpectedly with status %d",
- st->slip.nl.name,WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- fatal("%s: userv exited unexpectedly: uncaught signal %d",
- st->slip.nl.name,WTERMSIG(status));
- } else {
- fatal("%s: userv stopped unexpectedly",
- st->slip.nl.name);
- }
+ lg_exitstatus(0,st->slip.nl.name,0,
+ st->expecting_userv_exit ? M_WARNING : M_FATAL,
+ status,"userv");
}
- Message(M_WARNING,"%s: userv subprocess died with status %d\n",
- st->slip.nl.name,WEXITSTATUS(status));
st->pid=0;
}
if (errno==EINTR) continue;
FAIL("waitpid for authbind");
}
- if (WIFSIGNALED(status)) {
- lg_perror(FAIL_LG,0,"authbind died on signal %s (%d)",
- strsignal(WTERMSIG(status)),WTERMSIG(status));
- goto failed;
- }
- if (WIFEXITED(status) && WEXITSTATUS(status)!=0) {
- lg_perror(FAIL_LG,0,
- "authbind died with error exit status %d",
- WEXITSTATUS(status));
+ if (status) {
+ lg_exitstatus(FAIL_LG,status,"authbind");
goto failed;
}
} else {