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