home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / lbl / src / signals.c < prev   
Encoding:
C/C++ Source or Header  |  1986-11-30  |  845 b   |  39 lines

  1. /* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2.  *
  3.  *    Permission is hereby given to reproduce or modify this
  4.  *    software freely, provided that this notice be retained,
  5.  *    and that no use be made of the software for commercial
  6.  *    purposes without the express written permission of the
  7.  *    author.
  8.  */
  9.  
  10. /* signals.c:
  11.  *    provide clean-up after trapping external signals
  12.  */
  13.  
  14. #include    <lbl.h>
  15. #include    <signal.h>
  16.  
  17. extern char    tempname[];
  18.  
  19. int
  20. onsignal()
  21. {
  22.     unlink(tempname);
  23.     _exit(2);
  24. }
  25.  
  26. setsignals()
  27. {
  28.     int    (*oldsig)();
  29.  
  30.     if ((oldsig=signal(SIGINT, onsignal)) == SIG_IGN)
  31.         signal(SIGINT, SIG_IGN);
  32.     if ((oldsig=signal(SIGQUIT, onsignal)) == SIG_IGN)
  33.         signal(SIGQUIT, SIG_IGN);
  34.     if ((oldsig=signal(SIGHUP, onsignal)) == SIG_IGN)
  35.         signal(SIGHUP, SIG_IGN);
  36.     if ((oldsig=signal(SIGTERM, onsignal)) == SIG_IGN)
  37.         signal(SIGTERM, SIG_IGN);
  38. }
  39.