]>
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.
14 * auto-generated header
19 # define WTERMSIG(s) ((int)((s) & 0x7F))
23 # define WCOREDUMP(s) ((s) & 0x80)
27 pidstatus (int status
, FILE *fp
, char *cp
)
32 * I have no idea what this is for (rc)
33 * so I'm commenting it out for right now.
35 * if ((status & 0xff00) == 0xff00)
39 /* If child process returned normally */
40 if (WIFEXITED(status
)) {
41 if ((signum
= WEXITSTATUS(status
))) {
43 fprintf (fp
, "%s: ", cp
);
44 fprintf (fp
, "exit %d\n", signum
);
46 } else if (WIFSIGNALED(status
)) {
47 /* If child process terminated due to receipt of a signal */
48 signum
= WTERMSIG(status
);
49 if (signum
!= SIGINT
) {
51 fprintf (fp
, "%s: ", cp
);
52 fprintf (fp
, "signal %d", signum
);
53 if (signum
>= 0 && signum
< (int) sizeof(sigmsg
) &&
54 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)" : "");