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