
Xqdol() used to take quadratic time because of strcat(), the code isnt really needed as list2str() aready does the same thing in linear time without the strcat(). add estrdup() which uses emalloc() so allocation error are catched. move strdups() of name from callers into newvar(). avoid recursion of conclist(), and avoid copying of word strings by providing Newword() function which doesnt copy the word string.
37 lines
870 B
C
37 lines
870 B
C
#include "rc.h"
|
|
#include "exec.h"
|
|
#include "fns.h"
|
|
#include "io.h"
|
|
extern char *Signame[];
|
|
|
|
void
|
|
dotrap(void)
|
|
{
|
|
int i;
|
|
struct var *trapreq;
|
|
struct word *starval;
|
|
starval = vlook("*")->val;
|
|
while(ntrap) for(i = 0;i!=NSIG;i++) while(trap[i]){
|
|
--trap[i];
|
|
--ntrap;
|
|
if(getpid()!=mypid) Exit(getstatus());
|
|
trapreq = vlook(Signame[i]);
|
|
if(trapreq->fn){
|
|
start(trapreq->fn, trapreq->pc, (struct var *)0);
|
|
runq->local = newvar("*", runq->local);
|
|
runq->local->val = copywords(starval, (struct word *)0);
|
|
runq->local->changed = 1;
|
|
runq->redir = runq->startredir = 0;
|
|
}
|
|
else if(i==SIGINT || i==SIGQUIT){
|
|
/*
|
|
* 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();
|
|
}
|
|
else Exit(getstatus());
|
|
}
|
|
}
|