summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_exit.c2
-rw-r--r--sys/kern/tty.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 37d0254..673707f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -309,7 +309,7 @@ exit1(struct thread *td, int rv)
sp->s_ttyvp = NULL;
SESS_UNLOCK(sp);
- if (ttyvp != NULL) {
+ if (ttyvp != NULL && ttyvp->v_type != VBAD) {
/*
* Controlling process.
* Signal foreground pgrp and revoke access to
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 162ae37..bf800be 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1487,15 +1487,18 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
}
if (p->p_session->s_ttyvp != NULL ||
- (tp->t_session != NULL && tp->t_session->s_ttyvp != NULL)) {
+ (tp->t_session != NULL && tp->t_session->s_ttyvp != NULL &&
+ tp->t_session->s_ttyvp->v_type != VBAD)) {
/*
* There is already a relation between a TTY and
* a session, or the caller is not the session
* leader.
*
* Allow the TTY to be stolen when the vnode is
- * NULL, but the reference to the TTY is still
- * active.
+ * invalid, but the reference to the TTY is
+ * still active. This allows immediate reuse of
+ * TTYs of which the session leader has been
+ * killed or the TTY revoked.
*/
sx_xunlock(&proctree_lock);
return (EPERM);
OpenPOWER on IntegriCloud