]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
5a8d4d4ee72a4a1c7a44adefbb55f14b6f65ef98
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 # define WTERMSIG(s) ((int)((s) & 0x7F))
16 # define WCOREDUMP(s) ((s) & 0x80)
20 * Return 0 if the command exited with an exit code of zero, a nonzero code
23 * Print out an appropriate status message we didn't exit with an exit code
28 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
);
51 if (WIFSIGNALED(status
)) {
52 /* If child process terminated due to receipt of a signal */
53 signum
= WTERMSIG(status
);
54 if (signum
!= SIGINT
) {
56 fprintf (fp
, "%s: ", cp
);
57 fprintf (fp
, "signal %d", signum
);
59 signame
= strsignal(signum
);
63 fprintf (fp
, " (%s%s)\n", signame
,
64 WCOREDUMP(status
) ? ", core dumped" : "");
66 fprintf (fp
, "%s\n", WCOREDUMP(status
) ? " (core dumped)" : "");