diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 21:39:35 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 21:39:35 +0000 |
| commit | 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a (patch) | |
| tree | c6e220ba61db3a6ea4052e6841296d829654e664 /utils/rcsh/trap.c | |
| parent | 46439007cf417cbd9ac8049bb4122c890097a0fa (diff) | |
20060303
Diffstat (limited to 'utils/rcsh/trap.c')
| -rw-r--r-- | utils/rcsh/trap.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/rcsh/trap.c b/utils/rcsh/trap.c new file mode 100644 index 00000000..7bae2cbc --- /dev/null +++ b/utils/rcsh/trap.c @@ -0,0 +1,42 @@ +#include "rc.h" + +int interrupted; +Ref ntrap; + +/* runs in a different thread */ +void +dointr(void) +{ + refinc(&ntrap); + interrupted = 1; +} + +void +dotrap(void) +{ + Var *trapreq; + Word *starval; + + while(refdec(&ntrap) >= 0) { + if(flag['S']) + exits(truestatus()?"":getstatus()); + starval=vlook("*")->val; + trapreq=vlook("sysint"); + if(trapreq->fn){ + start(trapreq->fn, trapreq->pc, (Var*)0); + runq->local=newvar(strdup("*"), runq->local); + runq->local->val=copywords(starval, (Word*)0); + runq->local->changed=1; + runq->redir=runq->startredir=0; + } else { + /* + * run the stack down until we uncover the + * command reading loop. Xreturn will exit + * if there is none (i.e. if this is not + * an interactive rc.) + */ + while(!runq->iflag) + Xreturn(); + } + } +} |
