if ((tp->t_cflag & HUPCL) || ((tp->t_state & TS_ISOPEN) == 0)) { sabtty_mdmctrl(sc, 0, DMSET); sabtty_flush(sc); sabtty_reset(sc);
if ((tp->t_state & TS_ISOPEN) == 0) {  sc->sc_imr1 &= ~SAB_IMR1_ALLS; SAB_WRITE(sc, SAB_IMR1, sc->sc_imr1); sc->sc_flags |= SABTTYF_TXDRAIN; (void)tsleep(sc, TTIPRI, ttclos, 5 * hz); sc->sc_imr1 |= SAB_IMR1_ALLS; SAB_WRITE(sc, SAB_IMR1, sc->sc_imr1); sc->sc_flags &= ~SABTTYF_TXDRAIN;  if (tp->t_cflag & HUPCL) { sabtty_mdmctrl(sc, 0, DMSET); (void)tsleep(bc, TTIPRI, ttclos, hz); }  if ((sc->sc_flags & (SABTTYF_CONS_IN | SABTTYF_CONS_OUT)) == 0) {  sabtty_flush(sc); sabtty_reset(sc); }
sabttyclose(dev, flags, mode, p)	dev_t dev;	int flags, mode;	struct proc *p;{	struct sab_softc *bc = sab_cd.cd_devs[SAB_CARD(dev)];	struct sabtty_softc *sc = bc->sc_child[SAB_PORT(dev)];	struct tty *tp = sc->sc_tty;	int s;	(*linesw[tp->t_line].l_close)(tp, flags);	s = spltty();	if ((tp->t_cflag & HUPCL) || ((tp->t_state & TS_ISOPEN) == 0)) {		sabtty_mdmctrl(sc, 0, DMSET);		sabtty_flush(sc);		sabtty_reset(sc);	}	splx(s);	ttyclose(tp);	return (0);}