1: /* pidstatus.c - report child's status */ 2: 3: #include "../h/mh.h" 4: #include <signal.h> 5: #include <stdio.h> 6: 7: 8: #ifndef BSD42 9: static char *sigs[] = { 10: NULL, 11: "Hangup", 12: "Interrupt", 13: "Quit", 14: "Illegal instruction", 15: "Trace/BPT trap", 16: "IOT trap", 17: "EMT trap", 18: "Floating exception", 19: "Killed", 20: "Bus error", 21: "Segmentation fault", 22: "Bad system call", 23: "Broken pipe", 24: "Alarm clock", 25: "Terminated", 26: #ifdef SIGURG 27: "Urgent I/O condition", 28: #else 29: NULL, 30: #endif 31: "Stopped (signal)", 32: "Stopped", 33: "Continued", 34: "Child exited", 35: "Stopped (tty input)", 36: "Stopped (tty output)", 37: "Tty input interrupt", 38: "Cputime limit exceeded", 39: "Filesize limit exceeded", 40: NULL 41: }; 42: #else 43: extern char *sys_siglist[]; 44: #endif BSD42 45: 46: /* */ 47: 48: int pidstatus (status, fp, cp) 49: register int status; 50: register FILE *fp; 51: register char *cp; 52: { 53: int signum; 54: 55: if ((status & 0xff00) == 0xff00) 56: return status; 57: 58: switch (signum = status & 0x007f) { 59: case OK: 60: if (signum = ((status & 0xff00) >> 8)) { 61: if (cp) 62: fprintf (fp, "%s: ", cp); 63: fprintf (fp, "Exit %d\n", signum); 64: } 65: break; 66: 67: case SIGINT: 68: break; 69: 70: default: 71: if (cp) 72: fprintf (fp, "%s: ", cp); 73: #ifndef BSD42 74: if (signum >= sizeof sigs || sigs[signum] == NULL) 75: fprintf (fp, "Signal %d", signum); 76: else 77: fprintf (fp, "%s", sigs[signum]); 78: #else BSD42 79: if (signum >= NSIG) 80: fprintf (fp, "Signal %d", signum); 81: else 82: fprintf (fp, "%s", sys_siglist[signum]); 83: #endif BSD42 84: fprintf (fp, "%s\n", status & 0x80 ? " (core dumped)" : ""); 85: break; 86: } 87: 88: return status; 89: }