]>
diplodocus.org Git - nmh/blob - sbr/pidstatus.c
3 * pidstatus.c -- report child's status
11 * auto-generated header
15 #ifdef HAVE_SYS_WAIT_H
16 # include <sys/wait.h>
20 # define WTERMSIG(s) ((int)((s) & 0x7F))
24 # define WCOREDUMP(s) ((s) & 0x80)
28 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
);
47 } else if (WIFSIGNALED(status
)) {
48 /* If child process terminated due to receipt of a signal */
49 signum
= WTERMSIG(status
);
50 if (signum
!= SIGINT
) {
52 fprintf (fp
, "%s: ", cp
);
53 fprintf (fp
, "signal %d", signum
);
54 if (signum
>= 0 && signum
< sizeof(sigmsg
) && sigmsg
[signum
] != NULL
)
55 fprintf (fp
, " (%s%s)\n", sigmsg
[signum
],
56 WCOREDUMP(status
) ? ", core dumped" : "");
58 fprintf (fp
, "%s\n", WCOREDUMP(status
) ? " (core dumped)" : "");