| 371 | } |
| 372 | |
| 373 | static int |
| 374 | ttydev_close(struct cdev *dev, int fflag, int devtype __unused, |
| 375 | struct thread *td __unused) |
| 376 | { |
| 377 | struct tty *tp = dev->si_drv1; |
| 378 | |
| 379 | tty_lock(tp); |
| 380 | |
| 381 | /* |
| 382 | * Don't actually close the device if it is being used as the |
| 383 | * console. |
| 384 | */ |
| 385 | MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 || |
| 386 | (tp->t_flags & TF_OPENED_OUT) == 0); |
| 387 | if (dev == dev_console) |
| 388 | tp->t_flags &= ~TF_OPENED_CONS; |
| 389 | else |
| 390 | tp->t_flags &= ~(TF_OPENED_IN|TF_OPENED_OUT); |
| 391 | |
| 392 | if (tp->t_flags & TF_OPENED) { |
| 393 | tty_unlock(tp); |
| 394 | return (0); |
| 395 | } |
| 396 | |
| 397 | /* If revoking, flush output now to avoid draining it later. */ |
| 398 | if (fflag & FREVOKE) |
| 399 | tty_flush(tp, FWRITE); |
| 400 | |
| 401 | tp->t_flags &= ~TF_EXCLUDE; |
| 402 | |
| 403 | /* Properly wake up threads that are stuck - revoke(). */ |
| 404 | tp->t_revokecnt++; |
| 405 | tty_wakeup(tp, FREAD|FWRITE); |
| 406 | cv_broadcast(&tp->t_bgwait); |
| 407 | cv_broadcast(&tp->t_dcdwait); |
| 408 | |
| 409 | ttydev_leave(tp); |
| 410 | |
| 411 | return (0); |
| 412 | } |
| 413 | |
| 414 | static __inline int |
| 415 | tty_is_ctty(struct tty *tp, struct proc *p) |
nothing calls this directly
no test coverage detected