From: Ken Hornstein Date: Sat, 18 Jan 2014 05:38:39 +0000 (-0500) Subject: Explictly return the exit code, so we can portably guarantee that X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/4bc573a0c6adf03ac7154f99f479a30b56012ab9?ds=sidebyside;hp=-c Explictly return the exit code, so we can portably guarantee that pidstatus() will return 0 on a successful command execution. --- 4bc573a0c6adf03ac7154f99f479a30b56012ab9 diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index de1c55c6..1c1f7348 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -22,6 +22,14 @@ # define WCOREDUMP(s) ((s) & 0x80) #endif +/* + * Return 0 if the command exited with an exit code of zero, a nonzero code + * otherwise. + * + * Print out an appropriate status message we didn't exit with an exit code + * of zero. + */ + int pidstatus (int status, FILE *fp, char *cp) { @@ -42,6 +50,7 @@ pidstatus (int status, FILE *fp, char *cp) fprintf (fp, "%s: ", cp); fprintf (fp, "exit %d\n", signum); } + return signum; } else if (WIFSIGNALED(status)) { /* If child process terminated due to receipt of a signal */ signum = WTERMSIG(status);