1: /*******************************************************************************
   2:  *
   3:  *	signals	--	signal handling for dipress
   4:  *
   5:  *	William LeFebvre
   6:  *	with modifications by John Mellor-Crummey
   7:  *
   8:  *	Copyright (c) 1985 Xerox Corporation
   9:  ******************************************************************************/
  10: 
  11: #include <stdio.h>
  12: #include <signal.h>
  13: #include <sys/types.h>
  14: 
  15: #include "defs.h"   /* constant and macro definitions */
  16: #include "externs.h"    /* declarations for global variables */
  17: 
  18: int abortProcess();
  19: 
  20: /*-----------------------------------------------------------------------------
  21:  *	signalHandler	--	insure files are cleaned up properly upon exit
  22:  *				caused by an external signal
  23:  *---------------------------------------------------------------------------*/
  24: signalHandler()
  25: {
  26:     int goodbye();
  27: 
  28:     if ( signal(SIGINT, abortProcess) == (int (*)()) SIG_IGN)
  29:     {
  30:         /* if interrupts are turned off,
  31: 		 * disable other externally generated
  32: 		 * harmful signals
  33: 		 */
  34:         (void) signal(SIGINT, (int (*)()) SIG_IGN);
  35:         (void) signal(SIGQUIT, (int (*)()) SIG_IGN);
  36:         (void) signal(SIGHUP, (int (*)()) SIG_IGN);
  37:     }
  38:     else
  39:     {
  40:         (void) signal(SIGQUIT, goodbye);
  41:         (void) signal(SIGHUP, goodbye);
  42:     }
  43:     (void) signal(SIGTERM, abortProcess);
  44: }
  45: 
  46: /*-----------------------------------------------------------------------------
  47:  * abortProcess	--	signal handler that is called upon serious error
  48:  *---------------------------------------------------------------------------*/
  49: abortProcess()
  50: {
  51:     (void) close(pagebodyfile);
  52:     (void) unlink(tempfilename);
  53: 
  54:     (void) close(outputfile);
  55:     tempfilename[strlen(tempfilename) - 1] = '\0';
  56:     if (outputfile != fileno(stdout))
  57:         (void) unlink(tempfilename);
  58:     exit(1);
  59: }
  60: 
  61: 
  62: /*-----------------------------------------------------------------------------
  63:  * goodbye	--	function called for friendly cleanup
  64:  *---------------------------------------------------------------------------*/
  65: goodbye()
  66: {
  67:     if (outputfile == -1)
  68:         exit(1);
  69:     resetDevice();
  70:     exit(0);
  71: }

Defined functions

abortProcess defined in line 49; used 3 times
signalHandler defined in line 24; used 1 times
Last modified: 1986-01-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 978
Valid CSS Valid XHTML 1.0 Strict