| 212 | } |
| 213 | |
| 214 | static void ttydev_leave(struct lwp_tty *tp) |
| 215 | { |
| 216 | tty_assert_locked(tp); |
| 217 | |
| 218 | if (tty_opened(tp) || tp->t_flags & TF_OPENCLOSE) |
| 219 | { |
| 220 | /* Device is still opened somewhere. */ |
| 221 | tty_unlock(tp); |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | tp->t_flags |= TF_OPENCLOSE; |
| 226 | |
| 227 | /* Remove console TTY. */ |
| 228 | constty_clear(tp); |
| 229 | |
| 230 | /* Drain any output. */ |
| 231 | if (!tty_gone(tp)) |
| 232 | tty_drain(tp, 1); |
| 233 | |
| 234 | ttydisc_close(tp); |
| 235 | |
| 236 | /* Free i/o queues now since they might be large. */ |
| 237 | ttyinq_free(&tp->t_inq); |
| 238 | tp->t_inlow = 0; |
| 239 | ttyoutq_free(&tp->t_outq); |
| 240 | tp->t_outlow = 0; |
| 241 | |
| 242 | #ifdef USING_BSD_KNOTE |
| 243 | knlist_clear(&tp->t_inpoll.si_note, 1); |
| 244 | knlist_clear(&tp->t_outpoll.si_note, 1); |
| 245 | #endif |
| 246 | |
| 247 | if (!tty_gone(tp)) |
| 248 | ttydevsw_close(tp); |
| 249 | |
| 250 | tp->t_flags &= ~TF_OPENCLOSE; |
| 251 | cv_broadcast(&tp->t_dcdwait); |
| 252 | tty_rel_free(tp); |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * Operations that are exposed through the character device in /dev. |
no test coverage detected