3 * pidstatus.c -- report child's status
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
15 * auto-generated header
19 #ifdef HAVE_SYS_WAIT_H
20 # include <sys/wait.h>
24 # define WTERMSIG(s) ((int)((s) & 0x7F))
28 # define WCOREDUMP(s) ((s) & 0x80)
32 pidstatus (int status, FILE *fp, char *cp)
37 * I have no idea what this is for (rc)
38 * so I'm commenting it out for right now.
40 * if ((status & 0xff00) == 0xff00)
44 /* If child process returned normally */
45 if (WIFEXITED(status)) {
46 if ((signum = WEXITSTATUS(status))) {
48 fprintf (fp, "%s: ", cp);
49 fprintf (fp, "exit %d\n", signum);
51 } else if (WIFSIGNALED(status)) {
52 /* If child process terminated due to receipt of a signal */
53 signum = WTERMSIG(status);
54 if (signum != SIGINT) {
56 fprintf (fp, "%s: ", cp);
57 fprintf (fp, "signal %d", signum);
58 if (signum >= 0 && signum < sizeof(sigmsg) && sigmsg[signum] != NULL)
59 fprintf (fp, " (%s%s)\n", sigmsg[signum],
60 WCOREDUMP(status) ? ", core dumped" : "");
62 fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");