void redir_multi_com(t_mysh *mysh) { t_com *elem; int fd[2]; int fd_sauvg; pid_t pid; elem = mysh->tab_sel_ctrl.last; fd_sauvg = 0; pid = fork(); if (pid == 0) { while (elem && elem->prev) { pipe(fd); forker(fd_sauvg, fd[1], mysh, elem); elem = do_redir(elem, fd, mysh); close(fd[1]); fd_sauvg = fd[0]; } if (fd_sauvg != 0) dup2(fd_sauvg, 0); exec_multi_command(mysh, (elem) ? elem->com : NULL); } else my_waitpid(1, &mysh->ret_val); }
void disp(void) { register PD *p; /* take the process p */ /* off the ready list */ /* root */ p = rlr; rlr = p->p_link; #if DBG_GEMDISP kprintf("disp() to \"%8s\"\n", rlr->p_name); #endif /* based on the state */ /* of the process p */ /* do something */ if (p->p_stat & WAITIN) mwait_act(p); else disp_act(p); /* run through and */ /* execute all the */ /* fork processes */ do { if (fpcnt) { forker(); } schedule(); } while (fpcnt); /* switchto() is a machine dependent routine which: * 1) restores machine state * 2) clear "indisp" semaphore * 3) returns to appropriate address * so we'll never return from this */ switchto(rlr->p_uda); }
/* * Do a multi-wait on the specified events. */ WORD ev_multi(WORD flags, MOBLK *pmo1, MOBLK *pmo2, LONG tmcount, LONG buparm, LONG mebuff, WORD prets[]) { QPB m; register EVSPEC which; register WORD what; register CQUEUE *pc; /* say nothing has */ /* happened yet */ what = 0x0; which = 0; /* do a pre-check for a */ /* keystroke & then */ /* clear out the forkq*/ chkkbd(); forker(); /* a keystroke */ if (flags & MU_KEYBD) { /* if a character is */ /* ready then get it */ pc = &rlr->p_cda->c_q; if ( pc->c_cnt ) { prets[4] = (UWORD) dq(pc); what |= MU_KEYBD; } } /* if we own the mouse */ /* then do quick chks */ if ( rlr == gl_mowner ) { /* quick check button */ if (flags & MU_BUTTON) { if ( (mtrans > 1) && (downorup(pr_button, buparm)) ) { what |= MU_BUTTON; prets[5] = pr_mclick; } else { if ( downorup(button, buparm) ) { what |= MU_BUTTON; prets[5] = mclick; } } } /* quick check mouse rec*/ if ( ( flags & MU_M1 ) && ( in_mrect(pmo1) ) ) what |= MU_M1; /* quick check mouse rec*/ if ( ( flags & MU_M2 ) && ( in_mrect(pmo2) ) ) what |= MU_M2; } /* quick check timer */ if (flags & MU_TIMER) { if ( tmcount == 0x0L ) what |= MU_TIMER; } /* quick check message */ if (flags & MU_MESAG) { if ( rlr->p_qindex > 0 ) { ap_rdwr(MU_MESAG, rlr, 16, mebuff); what |= MU_MESAG; } } /* check for quick out */ /* if something has */ /* already happened */ if (what == 0x0) { /* wait for a keystroke */ if (flags & MU_KEYBD) iasync( MU_KEYBD, 0x0L ); /* wait for a button */ if (flags & MU_BUTTON) iasync( MU_BUTTON, buparm ); /* wait for mouse rect. */ if (flags & MU_M1) iasync( MU_M1, ADDR(pmo1) ); /* wait for mouse rect. */ if (flags & MU_M2) iasync( MU_M2, ADDR(pmo2) ); /* wait for message */ if (flags & MU_MESAG) { m.qpb_ppd = rlr; m.qpb_cnt = 16; m.qpb_buf = mebuff; iasync( MU_MESAG, ADDR(&m) ); } /* wait for timer */ if (flags & MU_TIMER) iasync( MU_TIMER, tmcount / gl_ticktime ); /* wait for events */ which = mwait( flags ); /* cancel outstanding */ /* events */ which |= acancel( flags ); } /* get the returns */ ev_rets(&prets[0]); /* do aprets() if */ /* something hasn't */ /* already happened */ if (what == 0x0) { what = which; if (which & MU_KEYBD) prets[4] = apret(MU_KEYBD); if (which & MU_BUTTON) prets[5] = apret(MU_BUTTON); if (which & MU_M1) apret(MU_M1); if (which & MU_M2) apret(MU_M2); if (which & MU_MESAG) apret(MU_MESAG); if (which & MU_TIMER) apret(MU_TIMER); } /* return what happened*/ return( what ); }