Ejemplo n.º 1
0
int ttflush(TTY tp, int mode)
{
	if (mode & 1)
	{
		qflush(&tp->inq);
	}
	
	if (mode & 2)
	{
		BCLR(tp->state, ST_STOPPED);
		ptsstop(tp,mode);
		qflush(&tp->outq);
		
		if (ISSET(tp->state,ST_DRAIN))
		{
			BCLR(tp->state, ST_DRAIN);
			Run(&tp->outq);
		}
	}

	return RPDONE;
}
Ejemplo n.º 2
0
static	int
ptsclose(struct dev_close_args *ap)
{
	cdev_t dev = ap->a_head.a_dev;
	struct tty *tp;
	struct pt_ioctl *pti = dev->si_drv1;
	int err;

	lwkt_gettoken(&tty_token);
	if (pti_hold(pti))
		panic("ptsclose on terminated pti");

	/*
	 * Disconnect the slave side
	 */
	tp = dev->si_tty;
	err = (*linesw[tp->t_line].l_close)(tp, ap->a_fflag);
	ptsstop(tp, FREAD|FWRITE);
	ttyclose(tp);			/* clears t_state */

	/*
	 * Mark the pts side closed and signal the ptc.  Do not mark the
	 * tty a zombie... that is, allow the tty to be re-opened as long
	 * as the ptc is still open.  The ptc will read() EOFs until the
	 * pts side is reopened or the ptc is closed.
	 *
	 * xterm() depends on this behavior as it will revoke() the pts
	 * and then reopen it after the (unnecessary old code) chmod.
	 */
	pti->pt_flags &= ~PF_SOPEN;
	pti->pt_flags |= PF_SCLOSED;
	if (tp->t_oproc)
		ptcwakeup(tp, FREAD);
	pti_done(pti);
	lwkt_reltoken(&tty_token);
	return (err);
}