Lines Matching refs:sp
106 register struct subshell *sp = subshell_data->pipe; in sh_subtmpfile() local
111 if((sp->tmpfd = fd = fcntl(1,F_DUPFD,10)) >= 0) in sh_subtmpfile()
143 if(sp && (shp->fdstatus[1]==IOCLOSE || (!shp->subshare && !(shp->fdstatus[1]&IONOSEEK)))) in sh_subtmpfile()
148 sp->pipefd = fds[0]; in sh_subtmpfile()
149 sh_fcntl(sp->pipefd,F_SETFD,FD_CLOEXEC); in sh_subtmpfile()
189 register struct subshell *sp = subshell_data; in sh_subfork() local
190 Shell_t *shp = sp->shp; in sh_subfork()
197 if(sp->pipe) in sh_subfork()
204 if(sp->subpid==0) in sh_subfork()
205 sp->subpid = pid; in sh_subfork()
221 sp->subpid=0; in sh_subfork()
228 register struct subshell *sp; in nv_subsaved() local
230 for(sp = (struct subshell*)subshell_data; sp; sp=sp->prev) in nv_subsaved()
232 for(lp=sp->svar; lp; lp = lp->next) in nv_subsaved()
250 register struct subshell *sp = (struct subshell*)subshell_data; in sh_assignok() local
252 Shell_t *shp = sp->shp; in sh_assignok()
258 if(!sp->shpwd || (nv_isnull(np) && !add) || np==SH_LEVELNOD) in sh_assignok()
262 dp = sp->var; in sh_assignok()
322 static void nv_restore(struct subshell *sp) in nv_restore() argument
326 const char *save = sp->shpwd; in nv_restore()
328 sp->shpwd = 0; /* make sure sh_assignok doesn't save with nv_unset() */ in nv_restore()
329 for(lp=sp->svar; lp; lp=lq) in nv_restore()
374 sp->svar = lq; in nv_restore()
376 sp->shpwd=save; in nv_restore()
385 register struct subshell *sp = subshell_data; in sh_subaliastree() local
386 if(!sp || sh.curenv==0) in sh_subaliastree()
388 if(!sp->salias && create) in sh_subaliastree()
390 sp->salias = dtopen(&_Nvdisc,Dtoset); in sh_subaliastree()
391 dtview(sp->salias,sh.alias_tree); in sh_subaliastree()
392 sh.alias_tree = sp->salias; in sh_subaliastree()
394 return(sp->salias); in sh_subaliastree()
403 register struct subshell *sp = subshell_data; in sh_subfuntree() local
404 if(!sp || sh.curenv==0) in sh_subfuntree()
406 if(!sp->sfun && create) in sh_subfuntree()
408 sp->sfun = dtopen(&_Nvdisc,Dtoset); in sh_subfuntree()
409 dtview(sp->sfun,sh.fun_tree); in sh_subfuntree()
410 sh.fun_tree = sp->sfun; in sh_subfuntree()
436 register struct subshell *sp = subshell_data; in sh_subsavefd() local
438 if(sp) in sh_subsavefd()
440 old = !(sp->fdsaved&(1<<(fd-1))); in sh_subsavefd()
441 sp->fdsaved |= (1<<(fd-1)); in sh_subsavefd()
448 register struct subshell *sp = subshell_data; in sh_subjobcheck() local
449 while(sp) in sh_subjobcheck()
451 if(sp->cpid==pid) in sh_subjobcheck()
453 sh_close(sp->coutpipe); in sh_subjobcheck()
454 sh_close(sp->cpipe); in sh_subjobcheck()
455 sp->coutpipe = sp->cpipe = -1; in sh_subjobcheck()
458 sp = sp->prev; in sh_subjobcheck()
473 register struct subshell *sp = &sub_data; in sh_subshell() local
483 memset((char*)sp, 0, sizeof(*sp)); in sh_subshell()
498 sp->prev = subshell_data; in sh_subshell()
499 sp->shp = shp; in sh_subshell()
500 sp->sig = 0; in sh_subshell()
501 subshell_data = sp; in sh_subshell()
502 sp->errcontext = &buff.err; in sh_subshell()
503 sp->var = shp->var_tree; in sh_subshell()
504 sp->options = shp->options; in sh_subshell()
505 sp->jobs = job_subsave(); in sh_subshell()
509 sp->pathlist = path_dup((Pathcomp_t*)shp->pathlist); in sh_subshell()
512 sp->bckpid = shp->bckpid; in sh_subshell()
515 sp->subshare = 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()
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()
545 sp->jobcontrol = job.jobcontrol; in sh_subshell()
546 sp->monitor = (sh_isstate(SH_MONITOR)!=0); in sh_subshell()
549 sp->pipe = sp; in sh_subshell()
551 sp->saveout = sfswap(sfstdout,NIL(Sfio_t*)); in sh_subshell()
552 sp->fdstatus = shp->fdstatus[1]; in sh_subshell()
553 sp->tmpfd = -1; in sh_subshell()
554 sp->pipefd = -1; in sh_subshell()
558 sfswap(sp->saveout,sfstdout); in sh_subshell()
564 if(!(sp->nofork = sh_state(SH_NOFORK))) in sh_subshell()
568 else if(sp->prev) in sh_subshell()
570 sp->pipe = sp->prev->pipe; in sh_subshell()
587 subshell_data = sp->prev; in sh_subshell()
596 if(!sp->nofork) in sh_subshell()
598 job.jobcontrol = sp->jobcontrol; in sh_subshell()
599 if(sp->monitor) in sh_subshell()
601 if(sp->pipefd>=0) in sh_subshell()
604 iop = sh_iostream(shp,sp->pipefd); in sh_subshell()
633 sfswap(sp->saveout,sfstdout); in sh_subshell()
635 if(sp->tmpfd>=0) in sh_subshell()
638 if (fcntl(sp->tmpfd,F_DUPFD,1) != 1) in sh_subshell()
640 sh_close(sp->tmpfd); in sh_subshell()
642 shp->fdstatus[1] = sp->fdstatus; in sh_subshell()
644 if(sp->subpid) in sh_subshell()
647 sp->sig = (shp->exitval&SH_EXITMASK); in sh_subshell()
650 shp->spid = sp->subpid; in sh_subshell()
652 if(comsub && iop && sp->pipefd<0) in sh_subshell()
655 shp->pathlist = (void*)sp->pathlist; in sh_subshell()
656 job_subrestore(sp->jobs); in sh_subshell()
659 shp->bckpid = sp->bckpid; in sh_subshell()
660 if(sp->shpwd) /* restore environment if saved */ in sh_subshell()
663 shp->options = sp->options; in sh_subshell()
664 nv_restore(sp); in sh_subshell()
665 if(sp->salias) in sh_subshell()
667 shp->alias_tree = dtview(sp->salias,0); in sh_subshell()
668 table_unset(sp->salias,0); in sh_subshell()
669 dtclose(sp->salias); in sh_subshell()
671 if(sp->sfun) in sh_subshell()
673 shp->fun_tree = dtview(sp->sfun,0); in sh_subshell()
674 table_unset(sp->sfun,1); in sh_subshell()
675 dtclose(sp->sfun); in sh_subshell()
688 shp->options = sp->options; in sh_subshell()
689 if(!shp->pwd || strcmp(sp->pwd,shp->pwd)) in sh_subshell()
695 chdir(shp->pwd=sp->pwd); in sh_subshell()
699 pwdnod->nvalue.cp = (const char*)sp->pwd; in sh_subshell()
701 else if(sp->shpwd != shp->pwd) in sh_subshell()
703 shp->pwd = sp->pwd; in sh_subshell()
704 if(PWDNOD->nvalue.cp==sp->shpwd) in sh_subshell()
705 PWDNOD->nvalue.cp = sp->pwd; in sh_subshell()
708 free((void*)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()
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()
724 subshell_data = sp->prev; in sh_subshell()
728 if(sp->sig) in sh_subshell()
730 if(sp->prev) in sh_subshell()
731 sp->prev->sig = sp->sig; in sh_subshell()
734 sh_fault(sp->sig); in sh_subshell()
740 if(sp->subpid && !comsub) in sh_subshell()
741 job_wait(sp->subpid); in sh_subshell()