- tp = &pt_tty[minor(dev)];
- if(tp->t_oproc) {
- (*linesw[tp->t_line].l_read)(tp);
- /* Wakeup other half if sleeping */
- wakeup((caddr_t)&tp->t_rawq.c_cf);
+again:
+ if (pti->pt_flags & PF_REMOTE) {
+ while (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) {
+ if (u.u_signal[SIGTTIN] == SIG_IGN ||
+ u.u_signal[SIGTTIN] == SIG_HOLD ||
+ /*
+ (u.u_procp->p_flag&SDETACH) ||
+ */
+ u.u_procp->p_flag&SVFORK)
+ return;
+ gsignal(u.u_procp->p_pgrp, SIGTTIN);
+ sleep((caddr_t)&lbolt, TTIPRI);
+ }
+ if (tp->t_rawq.c_cc == 0) {
+ if (tp->t_state & TS_NBIO) {
+ u.u_error = EWOULDBLOCK;
+ return;
+ }
+ sleep((caddr_t)&tp->t_rawq, TTIPRI);
+ goto again;
+ }
+ while (tp->t_rawq.c_cc > 1 && uio->uio_resid > 0)
+ if (ureadc(getc(&tp->t_rawq), uio) < 0) {
+ u.u_error = EFAULT;
+ break;
+ }
+ if (tp->t_rawq.c_cc == 1)
+ (void) getc(&tp->t_rawq);
+ if (tp->t_rawq.c_cc)
+ return;
+ } else
+ if (tp->t_oproc)
+ (*linesw[tp->t_line].l_read)(tp, uio);
+ wakeup((caddr_t)&tp->t_rawq.c_cf);
+ if (pti->pt_selw) {
+ selwakeup(pti->pt_selw, pti->pt_flags & PF_WCOLL);
+ pti->pt_selw = 0;
+ pti->pt_flags &= ~PF_WCOLL;