]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
1 /* pidstatus.c -- report child's status
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
12 * Return 0 if the command exited with an exit code of zero, a nonzero code
15 * Print out an appropriate status message we didn't exit with an exit code
20 pidstatus (int status
, FILE *fp
, char *cp
)
27 if (WIFEXITED(status
)) {
28 status
= WEXITSTATUS(status
);
31 fprintf (fp
, "%s: ", cp
);
32 fprintf(fp
, "exited %d\n", status
);
37 if (WIFSIGNALED(status
)) {
39 num
= WTERMSIG(status
);
43 } else if (WIFSTOPPED(status
)) {
45 num
= WSTOPSIG(status
);
47 } else if (WIFCONTINUED(status
)) {
52 mesg
= "bizarre wait(2) status";
58 fprintf(fp
, "%s: ", cp
);
62 fprintf(fp
, " %#x", num
);
65 signame
= strsignal(num
);
72 if (WCOREDUMP(status
))
73 fputs(", core dumped", fp
);