Lines Matching refs:shp

60 	Shell_t		*shp;	/* shell interpreter */
102 Shell_t *shp = &sh;
105 register struct checkpt *pp = (struct checkpt*)shp->jmplist;
114 shp->fdstatus[fd] = shp->fdstatus[1]|IOCLEX;
116 shp->fdstatus[1] = IOCLOSE;
120 ((struct checkpt*)shp->jmplist)->mode = SH_JMPERREXIT;
121 shp->toomany = 1;
124 if(shp->subshare || !pflag)
129 shp->fdstatus[fd] = IOREAD|IOWRITE;
136 shp->fdstatus[1] = shp->fdstatus[fd];
137 shp->fdstatus[fd] = IOCLOSE;
143 if(sp && (shp->fdstatus[1]==IOCLOSE || (!shp->subshare && !(shp->fdstatus[1]&IONOSEEK))))
164 if(fd==1 || ((shp->fdstatus[fd]&(IONOSEEK|IOSEEK|IOWRITE))!=(IOSEEK|IOWRITE)) || fstat(fd,&statx)<0)
173 sh_iostream(shp,1);
175 sfpool(sfstdout,shp->outpool,SF_WRITE);
190 Shell_t *shp = sp->shp;
191 int curenv = shp->curenv;
193 char *trap = shp->st.trapcom[0];
199 shp->curenv = 0;
202 shp->curenv = curenv;
208 siglongjmp(*shp->jmplist,SH_JMPSUB);
219 shp->subshell = 0;
222 shp->st.trapcom[0] = trap;
252 Shell_t *shp = sp->shp;
261 if(!(rp=shp->st.real_fun) || !(dp=rp->sdict))
263 if(np->nvenv && !nv_isattr(np,NV_MINIMAL|NV_EXPORT) && shp->last_root)
264 dp = shp->last_root;
272 shp->last_root = ap->table;
289 Dt_t *walk, *root=shp->var_tree;
311 save = shp->subshell;
312 shp->subshell = 0;
315 shp->subshell = save;
471 Shell_t *shp = &sh;
475 int savecurenv = shp->curenv;
484 sfsync(shp->outpool);
485 argsav = sh_arguse(shp);
486 if(shp->curenv==0)
491 shp->curenv = ++subenv;
493 savst = shp->st;
495 subshell = shp->subshell+1;
497 shp->subshell = subshell;
499 sp->shp = shp;
503 sp->var = shp->var_tree;
504 sp->options = shp->options;
507 if(!shp->pathlist)
509 sp->pathlist = path_dup((Pathcomp_t*)shp->pathlist);
510 if(!shp->pwd)
512 sp->bckpid = shp->bckpid;
515 sp->subshare = shp->subshare;
516 shp->subshare = comsub==2 || (comsub==1 && sh_isoption(SH_SUBSHARE));
517 if(!comsub || !shp->subshare)
519 sp->shpwd = shp->pwd;
520 sp->pwd = (shp->pwd?strdup(shp->pwd):0);
521 sp->mask = shp->mask;
524 shp->st.otrapcom = 0;
525 if((nsig=shp->st.trapmax*sizeof(char*))>0 || shp->st.trapcom[0])
528 memcpy(savsig=malloc(nsig),(char*)&shp->st.trapcom[0],nsig);
530 shp->st.otrapcom = (char**)savsig;
532 sp->cpid = shp->cpid;
533 sp->coutpipe = shp->coutpipe;
534 sp->cpipe = shp->cpipe[1];
535 shp->cpid = 0;
544 shp->spid = 0;
552 sp->fdstatus = shp->fdstatus[1];
563 shp->fdstatus[1] = IOWRITE;
575 if(comsub!=2 && jmpval!=SH_JMPSUB && shp->st.trapcom[0] && shp->subshell)
578 char *trap=shp->st.trapcom[0];
579 shp->st.trapcom[0] = 0; /* prevent recursion */
580 shp->oldexit = shp->exitval;
585 if(shp->subshell==0) /* must be child process */
589 siglongjmp(*shp->jmplist,jmpval);
590 shp->exitval &= SH_EXITMASK;
591 sh_done(shp,0);
604 iop = sh_iostream(shp,sp->pipefd);
622 shp->toomany = 1;
623 ((struct checkpt*)shp->jmplist)->mode = SH_JMPERREXIT;
626 shp->sftable[fd] = iop;
628 shp->fdstatus[fd] = (shp->fdstatus[1]|IOCLEX);
629 shp->fdstatus[1] = IOCLOSE;
642 shp->fdstatus[1] = sp->fdstatus;
646 if(shp->exitval > SH_EXITSIG)
647 sp->sig = (shp->exitval&SH_EXITMASK);
648 shp->exitval = 0;
650 shp->spid = sp->subpid;
654 path_delete((Pathcomp_t*)shp->pathlist);
655 shp->pathlist = (void*)sp->pathlist;
657 shp->jobenv = savecurenv;
659 shp->bckpid = sp->bckpid;
663 shp->options = sp->options;
667 shp->alias_tree = dtview(sp->salias,0);
673 shp->fun_tree = dtview(sp->sfun,0);
677 n = shp->st.trapmax-savst.trapmax;
680 memset(&shp->st.trapcom[savst.trapmax],0,n*sizeof(char*));
681 shp->st = savst;
682 shp->curenv = savecurenv;
685 memcpy((char*)&shp->st.trapcom[0],savsig,nsig);
688 shp->options = sp->options;
689 if(!shp->pwd || strcmp(sp->pwd,shp->pwd))
692 Namval_t *pwdnod = sh_scoped(shp,PWDNOD);
693 if(shp->pwd)
695 chdir(shp->pwd=sp->pwd);
696 path_newdir(shp->pathlist);
701 else if(sp->shpwd != shp->pwd)
703 shp->pwd = sp->pwd;
709 if(sp->mask!=shp->mask)
710 umask(shp->mask=sp->mask);
711 if(shp->coutpipe!=sp->coutpipe)
713 sh_close(shp->coutpipe);
714 sh_close(shp->cpipe[1]);
716 shp->cpid = sp->cpid;
717 shp->cpipe[1] = sp->cpipe;
718 shp->coutpipe = sp->coutpipe;
720 shp->subshare = sp->subshare;
721 if(shp->subshell)
722 SH_SUBSHELLNOD->nvalue.s = --shp->subshell;
723 subshell = shp->subshell;
725 sh_argfree(shp,argsav,0);
726 if(shp->topfd != buff.topfd)
727 sh_iorestore(shp,buff.topfd|IOSUBSHELL,jmpval);
739 shp->trapnote = 0;
742 if(shp->exitval > SH_EXITSIG)
744 int sig = shp->exitval&SH_EXITMASK;
750 ((struct checkpt*)shp->jmplist)->mode = SH_JMPERREXIT;
751 shp->toomany = 1;
754 if(jmpval && shp->toomany)
755 siglongjmp(*shp->jmplist,jmpval);