1 #include "rc.h" 2 3 int interrupted; 4 Ref ntrap; 5 6 /* runs in a different thread */ 7 void 8 dointr(void) 9 { 10 refinc(&ntrap); 11 interrupted = 1; 12 } 13 14 void 15 dotrap(void) 16 { 17 Var *trapreq; 18 Word *starval; 19 20 while(refdec(&ntrap) >= 0) { 21 if(flag['S']) 22 exits(truestatus()?"":getstatus()); 23 starval=vlook("*")->val; 24 trapreq=vlook("sysint"); 25 if(trapreq->fn){ 26 start(trapreq->fn, trapreq->pc, (Var*)0); 27 runq->local=newvar(strdup("*"), runq->local); 28 runq->local->val=copywords(starval, (Word*)0); 29 runq->local->changed=1; 30 runq->redir=runq->startredir=0; 31 } else { 32 /* 33 * run the stack down until we uncover the 34 * command reading loop. Xreturn will exit 35 * if there is none (i.e. if this is not 36 * an interactive rc.) 37 */ 38 while(!runq->iflag) 39 Xreturn(); 40 } 41 } 42 } 43