1: #include <whoami.h>
   2: #include <signal.h>
   3: #include <errno.h>
   4: /*
   5:  * signal system call interface package.
   6:  */
   7: 
   8: #define BYTESPERVEC 4           /* size of machine language vector */
   9: int errno;
  10: extern  char    mvectors[NSIG][BYTESPERVEC];    /* machine language vector */
  11: int touched[NSIG];
  12:                         /* really in I space */
  13: static  int (*cactions[NSIG])();        /* saved callers signal actions */
  14: static  char    setflg[NSIG];           /* flags for using sigset */
  15: int (*sigsys())();
  16: 
  17: int (*
  18: signal(signum, action))()
  19: register int signum;
  20: register int (*action)();
  21: {
  22:     register int (*retval)();
  23: 
  24:     if (signum <= 0 || signum > NSIG) {
  25:         errno = EINVAL;
  26:         return BADSIG;
  27:     }
  28:     retval = cactions[signum];
  29:     cactions[signum] = action;
  30:     if (action != SIG_IGN && action != SIG_DFL && action != SIG_HOLD)
  31:         if (SIGISDEFER(action))
  32:             action = DEFERSIG(mvectors[signum]);
  33:         else
  34:             action = (int (*)())(int)mvectors[signum];
  35:     action = sigsys(signum, action);
  36:     if (action == SIG_IGN || action == SIG_DFL || action == SIG_HOLD)
  37:         retval = action;
  38:     setflg[signum] = 0; /* indicate which kind of protocol */
  39:     return retval;
  40: }
  41: /*
  42:  * pretty much like the old signal call - set the action, return the
  43:  *	previous action and remember the action locally
  44:  */
  45: int (*
  46: sigset(signum, action))()
  47: register int signum;
  48: register int (*action)();
  49: {
  50:     register int (*retval)();
  51: 
  52:     if (signum <= 0 || signum > NSIG) {
  53:         errno = EINVAL;
  54:         return BADSIG;
  55:     }
  56:     retval = cactions[signum];
  57:     cactions[signum] = action;
  58:     if (action != SIG_IGN && action != SIG_DFL && action != SIG_HOLD)
  59:         action = DEFERSIG(mvectors[signum]);
  60:     action = sigsys(signum, action);
  61:     if (action == SIG_IGN || action == SIG_DFL || action == SIG_HOLD)
  62:         retval = action;
  63:     setflg[signum] = 1;
  64:     return retval;
  65: }
  66: 
  67: /* temporarily hold a signal until further notice - sigpause or sigrelse */
  68: 
  69: sighold(signum)
  70: register int signum;
  71: {
  72:     if (signum <= 0 || signum > NSIG)
  73:         abort();
  74:     /*
  75: 	 *	Bug fix to allow one to call sighold() then sigrelse()
  76: 	 *	to hold the default action rather than being forced
  77: 	 *	to call sigset (x, SIG_HOLD) then sigrelse.
  78: 	 */
  79:     setflg[signum] = 1;
  80:     sigsys(signum, SIG_HOLD);
  81: }
  82: 
  83: /* atomically release the signal and pause (if none pending) */
  84: /* if no other signal has occurred, the signal will be held upon return */
  85: sigpause(signum)
  86: register signum;
  87: {
  88:     if (signum <= 0 || signum > NSIG || setflg[signum] == 0)
  89:         abort();
  90:     sigsys(signum | SIGDOPAUSE, DEFERSIG(mvectors[signum]));
  91:     /* sigsys(signum , DEFERSIG(mvectors[signum]));
  92: 	pause(); */
  93: }
  94: 
  95: /* re-enable signals after sighold or possibly after sigpause */
  96: 
  97: sigrelse(signum)
  98: register signum;
  99: {
 100:     if (signum <= 0 || signum > NSIG || setflg[signum] == 0)
 101:         abort();
 102:     sigsys(signum, DEFERSIG(mvectors[signum]));
 103: }
 104: 
 105: /* ignore these signals */
 106: 
 107: sigignore(signum)
 108: {
 109:     sigsys(signum, SIG_IGN);
 110: }
 111: /* called by the machine language assist at interrupt time */
 112: /* return value is new signal action (if any) */
 113: int (*
 114: _sigcatch(signum))()
 115: register signum;
 116: {
 117: touched[signum]++;
 118:     (*cactions[signum])(signum);        /* call the C routine */
 119: 
 120:     if (setflg[signum])
 121:         return DEFERSIG(mvectors[signum]);  /* return new action to set */
 122:     else
 123:         return SIG_DFL;
 124: }
 125: 
 126: /* machine language assist is at interrupt time, where it vectors in,
 127:  * determining the caught signal and passing it to _sigcatch.
 128:  * its main purpose in life is to ensure that ALL registers are saved.
 129:  * and figuring out which signal is being caught
 130:  */

Defined functions

sigignore defined in line 107; used 3 times
sigpause defined in line 85; used 2 times

Defined variables

errno defined in line 9; used 2 times
setflg defined in line 14; used 6 times
signum defined in line 115; used 45 times
touched defined in line 11; used 1 times

Defined macros

BYTESPERVEC defined in line 8; used 1 times
  • in line 10
Last modified: 1982-09-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 796
Valid CSS Valid XHTML 1.0 Strict