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
18 # define WTERMSIG(s) ((int)((s) & 0x7F))
22 # define WCOREDUMP(s) ((s) & 0x80)
26 pidstatus(int status, FILE *fp, char *cp)
31 ** I have no idea what this is for (rc)
32 ** so I'm commenting it out for right now.
34 ** if ((status & 0xff00) == 0xff00)
38 /* If child process returned normally */
39 if (WIFEXITED(status)) {
40 if ((signum = WEXITSTATUS(status))) {
42 fprintf(fp, "%s: ", cp);
43 fprintf(fp, "exit %d\n", signum);
45 } else if (WIFSIGNALED(status)) {
46 /* If child process terminated due to receipt of a signal */
47 signum = WTERMSIG(status);
48 if (signum != SIGINT) {
50 fprintf(fp, "%s: ", cp);
51 fprintf(fp, "signal %d", signum);
52 if (signum >= 0 && signum < (int)sizeof(sigmsg) &&
53 sigmsg[signum] != NULL)
54 fprintf(fp, " (%s%s)\n", sigmsg[signum],
55 WCOREDUMP(status) ? ", core dumped" : "");
57 fprintf(fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");