home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / conf2 / part04 / confsig.c next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  900 b   |  51 lines

  1. #include "conf.h"
  2.  
  3. int nsig = 16;
  4.  
  5. char *sig_list[] =
  6. {
  7.     "Unkown Signal: 0",
  8.     "Hangup",
  9.     "Interrupt",
  10.     "Quit",
  11.     "Illegal Instruction",
  12.     "Trace Trap", 
  13.     "IOT Instruction",
  14.     "EMT Instruction",
  15.     "Floating Point Exception",
  16.     "Kill",
  17.     "Bus Error",
  18.     "Segmentation Violation",
  19.     "Bad Argument To System Call",
  20.     "Write On A Pipe With No One To Read It",
  21.     "Alarm Clock",
  22.     "Software Termination Signal From Kill",
  23. };
  24.  
  25. fatal(sig)
  26. int sig;
  27. {
  28.     int p;
  29.  
  30.     (void) printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
  31.     make_nice(FALSE);
  32.  
  33.     p = kill(cuser.cu_procid, sig);
  34.     if (p < 0)
  35.     (void) fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
  36.                progname, cuser.cu_procid, puterr(errno));
  37.  
  38.     (void) exit(-1);
  39. }
  40.  
  41. char *
  42. putsig(sig)
  43. int sig;
  44. {
  45.     static char qwerty[42];
  46.  
  47.     (void) sprintf(qwerty, "Unknown Signal: %d", sig);
  48.  
  49.     return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
  50. }
  51.