]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
f8a37f393026ca21e75ec574dbb0f06d802facd3
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
)
32 /* If child process returned normally */
33 if (WIFEXITED(status
)) {
34 if ((signum
= WEXITSTATUS(status
))) {
36 fprintf (fp
, "%s: ", cp
);
37 fprintf (fp
, "exit %d\n", signum
);
42 if (WIFSIGNALED(status
)) {
43 /* If child process terminated due to receipt of a signal */
44 signum
= WTERMSIG(status
);
45 if (signum
!= SIGINT
) {
47 fprintf (fp
, "%s: ", cp
);
48 fprintf (fp
, "signal %d", signum
);
50 signame
= strsignal(signum
);
54 fprintf (fp
, " (%s%s)\n", signame
,
55 WCOREDUMP(status
) ? ", core dumped" : "");
57 if (WCOREDUMP(status
))
58 fputs(" (core dumped)", fp
);