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