diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 9c1911b..163dfc3 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -302,8 +302,12 @@ pti_done(struct pt_ioctl *pti) * Interlock open attempts against termination by setting * PF_TERMINATED. This allows us to block while cleaning * out the device infrastructure. + * + * Do not terminate the tty if it still has a session + * association. */ - if ((pti->pt_flags2 & (PF_SOPEN|PF_MOPEN)) == 0) { + if ((pti->pt_flags2 & (PF_SOPEN|PF_MOPEN)) == 0 && + pti->pt_tty.t_session == NULL) { pti->pt_flags2 |= PF_TERMINATED; uminor_no = pti->pt_uminor;