void fg_proc_entry(struct process *pp) { jmp_buf_t osetexit; int ohaderr; Char oGettingInput; size_t omark; getexit(osetexit); pintr_disabled++; oGettingInput = GettingInput; GettingInput = 0; ohaderr = haderr; /* we need to ignore setting of haderr due to * process getting stopped by a signal */ omark = cleanup_push_mark(); if (setexit() == 0) { /* come back here after pjwait */ pendjob(); (void) alarm(0); /* No autologout */ alrmcatch_disabled = 1; if (!pstart(pp, 1)) { pp->p_procid = 0; stderror(ERR_BADJOB, pp->p_command, strerror(errno)); } pjwait(pp); } setalarm(1); /* Autologout back on */ cleanup_pop_mark(omark); resexit(osetexit); haderr = ohaderr; GettingInput = oGettingInput; disabled_cleanup(&pintr_disabled); }
/* * pwait - wait for current job to terminate, maintaining integrity * of current and previous job indicators. */ pwait() { register struct process *fp, *pp; int omask; /* * Here's where dead procs get flushed. */ omask = sigblock(sigmask(SIGCHLD)); for (pp = (fp = &proclist)->p_next; pp != PNULL; pp = (fp = pp)->p_next) if (pp->p_pid == 0) { fp->p_next = pp->p_next; xfree(pp->p_command); if (pp->p_cwd && --pp->p_cwd->di_count == 0) if (pp->p_cwd->di_next == 0) dfree(pp->p_cwd); xfree((char *)pp); pp = fp; } (void) sigsetmask(omask); pjwait(pcurrjob); }