SCCS-vsn: sys/kern/tty_pty.c 7.5
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)tty_pty.c 7.4 (Berkeley) %G%
+ * @(#)tty_pty.c 7.5 (Berkeley) %G%
} pt_ioctl[NPTY];
int npty = NPTY; /* for pstat -t */
} pt_ioctl[NPTY];
int npty = NPTY; /* for pstat -t */
#define PF_RCOLL 0x0001
#define PF_WCOLL 0x0002
#define PF_NBIO 0x0004
#define PF_RCOLL 0x0001
#define PF_WCOLL 0x0002
#define PF_NBIO 0x0004
tp->t_state |= TS_CARR_ON;
while ((tp->t_state & TS_CARR_ON) == 0) {
tp->t_state |= TS_WOPEN;
tp->t_state |= TS_CARR_ON;
while ((tp->t_state & TS_CARR_ON) == 0) {
tp->t_state |= TS_WOPEN;
+ if (flag&FNDELAY)
+ break;
sleep((caddr_t)&tp->t_rawq, TTIPRI);
}
sleep((caddr_t)&tp->t_rawq, TTIPRI);
}
- error = (*linesw[tp->t_line].l_open)(dev, tp);
+ error = (*linesw[tp->t_line].l_open)(dev, tp, flag);
ptcwakeup(tp, FREAD|FWRITE);
return (error);
}
ptcwakeup(tp, FREAD|FWRITE);
return (error);
}
dev_t dev;
struct uio *uio;
{
dev_t dev;
struct uio *uio;
{
sleep((caddr_t)&lbolt, TTIPRI);
}
if (tp->t_canq.c_cc == 0) {
sleep((caddr_t)&lbolt, TTIPRI);
}
if (tp->t_canq.c_cc == 0) {
- if (tp->t_state & TS_NBIO)
return (EWOULDBLOCK);
sleep((caddr_t)&tp->t_canq, TTIPRI);
goto again;
return (EWOULDBLOCK);
sleep((caddr_t)&tp->t_canq, TTIPRI);
goto again;
return (error);
} else
if (tp->t_oproc)
return (error);
} else
if (tp->t_oproc)
- error = (*linesw[tp->t_line].l_read)(tp, uio);
+ error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
ptcwakeup(tp, FWRITE);
return (error);
}
ptcwakeup(tp, FWRITE);
return (error);
}
* Wakeups of controlling tty will happen
* indirectly, when tty driver calls ptsstart.
*/
* Wakeups of controlling tty will happen
* indirectly, when tty driver calls ptsstart.
*/
+ptswrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
{
dev_t dev;
struct uio *uio;
{
sleep((caddr_t)pti + 1, TTOPRI);
}
sleep((caddr_t)pti + 1, TTOPRI);
}
- return ((*linesw[tp->t_line].l_write)(tp, uio));
+ return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
pti->pt_selw = 0;
pti->pt_flags &= ~PF_WCOLL;
}
pti->pt_selw = 0;
pti->pt_flags &= ~PF_WCOLL;
}
+if (ptydebug) printf("WAKEUP c_cf %d\n", u.u_procp->p_pid);
wakeup((caddr_t)&tp->t_rawq.c_cf);
}
}
wakeup((caddr_t)&tp->t_rawq.c_cf);
}
}
dev_t dev;
struct uio *uio;
{
dev_t dev;
struct uio *uio;
{
break;
}
if ((tp->t_state&TS_CARR_ON) == 0)
break;
}
if ((tp->t_state&TS_CARR_ON) == 0)
- return (EIO);
- if (pti->pt_flags&PF_NBIO)
+ return (0); /* EOF */
+ if (flag&FNDELAY)
+if (ptydebug) printf("SLEEP(1) c_cf %d\n", u.u_procp->p_pid);
sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
}
if (pti->pt_flags & (PF_PKT|PF_UCNTL|PF_TIOC))
sleep((caddr_t)&tp->t_outq.c_cf, TTIPRI);
}
if (pti->pt_flags & (PF_PKT|PF_UCNTL|PF_TIOC))
+ptcwrite(dev, uio, flag)
dev_t dev;
register struct uio *uio;
{
dev_t dev;
register struct uio *uio;
{
wakeup((caddr_t)&tp->t_rawq);
goto block;
}
wakeup((caddr_t)&tp->t_rawq);
goto block;
}
- (*linesw[tp->t_line].l_rint)(*cp++, tp);
+ (*linesw[tp->t_line].l_rint)(*cp++&0377, tp);
*/
if ((tp->t_state&TS_CARR_ON) == 0)
return (EIO);
*/
if ((tp->t_state&TS_CARR_ON) == 0)
return (EIO);
- if (pti->pt_flags & PF_NBIO) {
+ if ((pti->pt_flags & PF_NBIO) || (flag & FNDELAY)) {
iov->iov_base -= cc;
iov->iov_len += cc;
uio->uio_resid += cc;
iov->iov_base -= cc;
iov->iov_len += cc;
uio->uio_resid += cc;
return (EWOULDBLOCK);
return (0);
}
return (EWOULDBLOCK);
return (0);
}
+if (ptydebug) printf("SLEEP(2) c_cf %d\n", u.u_procp->p_pid);
sleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI);
goto again;
}
sleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI);
goto again;
}
if (linesw[tp->t_line].l_rint != ttyinput) {
(*linesw[tp->t_line].l_close)(tp);
tp->t_line = 0;
if (linesw[tp->t_line].l_rint != ttyinput) {
(*linesw[tp->t_line].l_close)(tp);
tp->t_line = 0;
- (void)(*linesw[tp->t_line].l_open)(dev, tp);
+ (void)(*linesw[tp->t_line].l_open)(dev, tp, flag);