]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
3 * pidstatus.c -- report child's status
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
13 # define WTERMSIG(s) ((int)((s) & 0x7F))
17 # define WCOREDUMP(s) ((s) & 0x80)
21 * Return 0 if the command exited with an exit code of zero, a nonzero code
24 * Print out an appropriate status message we didn't exit with an exit code
29 pidstatus (int status
, FILE *fp
, char *cp
)
35 * I have no idea what this is for (rc)
36 * so I'm commenting it out for right now.
38 * if ((status & 0xff00) == 0xff00)
42 /* If child process returned normally */
43 if (WIFEXITED(status
)) {
44 if ((signum
= WEXITSTATUS(status
))) {
46 fprintf (fp
, "%s: ", cp
);
47 fprintf (fp
, "exit %d\n", signum
);
52 if (WIFSIGNALED(status
)) {
53 /* If child process terminated due to receipt of a signal */
54 signum
= WTERMSIG(status
);
55 if (signum
!= SIGINT
) {
57 fprintf (fp
, "%s: ", cp
);
58 fprintf (fp
, "signal %d", signum
);
60 signame
= strsignal(signum
);
64 fprintf (fp
, " (%s%s)\n", signame
,
65 WCOREDUMP(status
) ? ", core dumped" : "");
67 fprintf (fp
, "%s\n", WCOREDUMP(status
) ? " (core dumped)" : "");