]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
1 /* pidstatus.c -- report child's status
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
11 # define WTERMSIG(s) ((int)((s) & 0x7F))
15 # define WCOREDUMP(s) ((s) & 0x80)
19 * Return 0 if the command exited with an exit code of zero, a nonzero code
22 * Print out an appropriate status message we didn't exit with an exit code
27 pidstatus (int status
, FILE *fp
, char *cp
)
33 * I have no idea what this is for (rc)
34 * so I'm commenting it out for right now.
36 * if ((status & 0xff00) == 0xff00)
40 /* If child process returned normally */
41 if (WIFEXITED(status
)) {
42 if ((signum
= WEXITSTATUS(status
))) {
44 fprintf (fp
, "%s: ", cp
);
45 fprintf (fp
, "exit %d\n", signum
);
50 if (WIFSIGNALED(status
)) {
51 /* If child process terminated due to receipt of a signal */
52 signum
= WTERMSIG(status
);
53 if (signum
!= SIGINT
) {
55 fprintf (fp
, "%s: ", cp
);
56 fprintf (fp
, "signal %d", signum
);
58 signame
= strsignal(signum
);
62 fprintf (fp
, " (%s%s)\n", signame
,
63 WCOREDUMP(status
) ? ", core dumped" : "");
65 fprintf (fp
, "%s\n", WCOREDUMP(status
) ? " (core dumped)" : "");