1: #
   2: /*
   3:  * UNIX shell
   4:  *
   5:  * S. R. Bourne
   6:  * Bell Telephone Laboratories
   7:  *
   8:  */
   9: 
  10: #include    "defs.h"
  11: 
  12: 
  13: STRING      trapcom[MAXTRAP];
  14: BOOL        trapflg[MAXTRAP];
  15: 
  16: /* ========	fault handling routines	   ======== */
  17: 
  18: 
  19: VOID    fault(sig)
  20:     REG INT     sig;
  21: {
  22:     REG INT     flag;
  23: 
  24:     signal(sig,fault);
  25:     IF sig==MEMF
  26:     THEN    IF setbrk(brkincr) == -1
  27:         THEN    error(nospace);
  28:         FI
  29:     ELIF sig==ALARM
  30:     THEN    IF flags&waiting
  31:         THEN    done();
  32:         FI
  33:     ELSE    flag = (trapcom[sig] ? TRAPSET : SIGSET);
  34:         trapnote |= flag;
  35:         trapflg[sig] |= flag;
  36:     FI
  37: }
  38: 
  39: stdsigs()
  40: {
  41:     ignsig(QUIT);
  42:     getsig(INTR);
  43:     getsig(MEMF);
  44:     getsig(ALARM);
  45: }
  46: 
  47: ignsig(n)
  48: {
  49:     REG INT     s, i;
  50: 
  51:     IF (s=signal(i=n,1)&01)==0
  52:     THEN    trapflg[i] |= SIGMOD;
  53:     FI
  54:     return(s);
  55: }
  56: 
  57: getsig(n)
  58: {
  59:     REG INT     i;
  60: 
  61:     IF trapflg[i=n]&SIGMOD ORF ignsig(i)==0
  62:     THEN    signal(i,fault);
  63:     FI
  64: }
  65: 
  66: oldsigs()
  67: {
  68:     REG INT     i;
  69:     REG STRING  t;
  70: 
  71:     i=MAXTRAP;
  72:     WHILE i--
  73:     DO  t=trapcom[i];
  74:         IF t==0 ORF *t
  75:         THEN clrsig(i);
  76:         FI
  77:         trapflg[i]=0;
  78:     OD
  79:     trapnote=0;
  80: }
  81: 
  82: clrsig(i)
  83:     INT     i;
  84: {
  85:     free(trapcom[i]); trapcom[i]=0;
  86:     IF trapflg[i]&SIGMOD
  87:     THEN    signal(i,fault);
  88:         trapflg[i] &= ~SIGMOD;
  89:     FI
  90: }
  91: 
  92: chktrap()
  93: {
  94:     /* check for traps */
  95:     REG INT     i=MAXTRAP;
  96:     REG STRING  t;
  97: 
  98:     trapnote &= ~TRAPSET;
  99:     WHILE --i
 100:     DO IF trapflg[i]&TRAPSET
 101:        THEN trapflg[i] &= ~TRAPSET;
 102:         IF t=trapcom[i]
 103:         THEN    INT savxit=exitval;
 104:             execexp(t,0);
 105:             exitval=savxit; exitset();
 106:         FI
 107:        FI
 108:     OD
 109: }

Defined functions

chktrap defined in line 92; used 2 times
clrsig defined in line 82; used 2 times
fault defined in line 19; used 4 times
getsig defined in line 57; used 4 times
ignsig defined in line 47; used 4 times
oldsigs defined in line 66; used 2 times
stdsigs defined in line 39; used 1 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 956
Valid CSS Valid XHTML 1.0 Strict