Remove RCS keywords, since they no longer work after git migration.
[mmh] / sbr / pidstatus.c
1
2 /*
3  * pidstatus.c -- report child's status
4  *
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.
8  */
9
10 #include <h/mh.h>
11
12 /*
13  * auto-generated header
14  */
15 #include <sigmsg.h>
16
17 #ifdef HAVE_SYS_WAIT_H
18 # include <sys/wait.h>
19 #endif
20
21 #ifndef WTERMSIG
22 # define WTERMSIG(s) ((int)((s) & 0x7F))
23 #endif
24
25 #ifndef WCOREDUMP
26 # define WCOREDUMP(s) ((s) & 0x80)
27 #endif
28
29 int
30 pidstatus (int status, FILE *fp, char *cp)
31 {
32     int signum;
33
34 /*
35  * I have no idea what this is for (rc)
36  * so I'm commenting it out for right now.
37  *
38  *  if ((status & 0xff00) == 0xff00)
39  *      return status;
40  */
41
42     /* If child process returned normally */
43     if (WIFEXITED(status)) {
44         if ((signum = WEXITSTATUS(status))) {
45             if (cp)
46                 fprintf (fp, "%s: ", cp);
47             fprintf (fp, "exit %d\n", signum);
48         }
49     } else if (WIFSIGNALED(status)) {
50         /* If child process terminated due to receipt of a signal */
51         signum = WTERMSIG(status);
52         if (signum != SIGINT) {
53             if (cp)
54                 fprintf (fp, "%s: ", cp);
55             fprintf (fp, "signal %d", signum);
56             if (signum >= 0 && signum < sizeof(sigmsg) && sigmsg[signum] != NULL)
57                 fprintf (fp, " (%s%s)\n", sigmsg[signum],
58                          WCOREDUMP(status) ? ", core dumped" : "");
59             else
60                 fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");
61         }
62     }
63
64     return status;
65 }