home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / conf / part04 / confsig.c next >
Encoding:
C/C++ Source or Header  |  1988-03-13  |  1.7 KB  |  94 lines

  1.  
  2. /*
  3.  *    conf - An interactive multi-user chat program.
  4.  *
  5.  *    conf Copyright (c) 1986, 1987 by Keith Gabryelski
  6.  *
  7.  *    Conf is quasi-public domain software; it may be used and copied
  8.  *    freely and may be modified to suit the indivuals needs as long
  9.  *    as:
  10.  *
  11.  *    [1] It is not sold.
  12.  *    [2] It is not made part of any licensed product.
  13.  *    [3] This header and others like it are not modified or removed.
  14.  *    [4] You allow others to use and copy without charge.
  15.  *    
  16.  *    without expressed written permission from the original
  17.  *    author (Keith Gabryelski).
  18.  *
  19.  *
  20.  */
  21.  
  22. #include "conf.h"
  23.  
  24. int nsig = 16;
  25.  
  26. char *sig_list[] =
  27. {
  28.     "Unkown Signal: 0",
  29.     "Hangup",
  30.     "Interrupt",
  31.     "Quit",
  32.     "Illegal Instruction",
  33.     "Trace Trap", 
  34.     "IOT Instruction",
  35.     "EMT Instruction",
  36.     "Floating Point Exception",
  37.     "Kill",
  38.     "Bus Error",
  39.     "Segmentation Violation",
  40.     "Bad Argument To System Call",
  41.     "Write On A Pipe With No One To Read It",
  42.     "Alarm Clock",
  43.     "Software Termination Signal From Kill",
  44. };
  45.  
  46. fatal(sig)
  47. int sig;
  48. {
  49.     int c, p;
  50.  
  51.     (void)printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
  52.     make_nice(FALSE);
  53.     if (askdump || (sig == SIGQUIT))
  54.     {
  55.     p = TRUE;
  56.     (void)fputs("dump core? [y] ", stdout);
  57.     while(((c = getchar()) != '\n') && (c != EOF))
  58.     {
  59.         switch(c)
  60.         {
  61.         case 'y':
  62.         case 'Y':
  63.             p = TRUE;
  64.             break;
  65.  
  66.         case 'n':
  67.         case 'N':
  68.             p = FALSE;
  69.             break;
  70.         }
  71.     }
  72.  
  73.     if (p)
  74.     {
  75.         p = kill(cuser.cu_procid, sig);
  76.         if (p <0)
  77.         (void)fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
  78.             progname, cuser.cu_procid, puterr(errno));
  79.     }
  80.     }
  81.     (void) exit(-1);
  82. }
  83.  
  84. char *
  85. putsig(sig)
  86. int sig;
  87. {
  88.     static char qwerty[42];
  89.  
  90.     (void)sprintf(qwerty, "Unknown Signal: %d", sig);
  91.  
  92.     return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
  93. }
  94.