source: trunk/third/nmh/sbr/pidstatus.c @ 12455

Revision 12455, 1.3 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * pidstatus.c -- report child's status
4 *
5 * $Id: pidstatus.c,v 1.1.1.1 1999-02-07 18:14:09 danw Exp $
6 */
7
8#include <h/mh.h>
9
10/*
11 * auto-generated header
12 */
13#include <sigmsg.h>
14
15#ifdef HAVE_SYS_WAIT_H
16# include <sys/wait.h>
17#endif
18
19#ifndef WTERMSIG
20# define WTERMSIG(s) ((int)((s) & 0x7F))
21#endif
22
23#ifndef WCOREDUMP
24# define WCOREDUMP(s) ((s) & 0x80)
25#endif
26
27int
28pidstatus (int status, FILE *fp, char *cp)
29{
30    int signum;
31
32/*
33 * I have no idea what this is for (rc)
34 * so I'm commenting it out for right now.
35 *
36 *  if ((status & 0xff00) == 0xff00)
37 *      return status;
38 */
39
40    /* If child process returned normally */
41    if (WIFEXITED(status)) {
42        if ((signum = WEXITSTATUS(status))) {
43            if (cp)
44                fprintf (fp, "%s: ", cp);
45            fprintf (fp, "exit %d\n", signum);
46        }
47    } else if (WIFSIGNALED(status)) {
48        /* If child process terminated due to receipt of a signal */
49        signum = WTERMSIG(status);
50        if (signum != SIGINT) {
51            if (cp)
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" : "");
57            else
58                fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");
59        }
60    }
61
62    return status;
63}
Note: See TracBrowser for help on using the repository browser.