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.
13 ** auto-generated header
19 # define WTERMSIG(s) ((int)((s) & 0x7F))
23 # define WCOREDUMP(s) ((s) & 0x80)
27 pidstatus(int status, FILE *fp, char *cp)
32 ** I have no idea what this is for (rc)
33 ** so I'm commenting it out for right now.
35 ** if ((status & 0xff00) == 0xff00)
39 if (WIFEXITED(status)) {
40 /* child process returned normally */
41 if ((signum = WEXITSTATUS(status))) {
43 fprintf(fp, "%s: ", cp);
45 fprintf(fp, "exit %d\n", signum);
47 } else if (WIFSIGNALED(status)) {
48 /* child process terminated due to receipt of a signal */
49 signum = WTERMSIG(status);
50 if (signum == SIGINT) {
54 fprintf(fp, "%s: ", cp);
56 fprintf(fp, "signal %d", signum);
57 if (signum >= 0 && signum < (int)sizeof(sigmsg) &&
58 sigmsg[signum] != NULL) {
59 fprintf(fp, " (%s%s)\n", sigmsg[signum],
61 ", core dumped" : "");
63 fprintf(fp, "%s\n", WCOREDUMP(status) ?
64 " (core dumped)" : "");
73 pidXwait(int pid, char *cp)
75 return pidstatus(pidwait(pid, -1), stdout, cp);