cnclose() doesn't actually call TTY's close routines

Ed Schouten ed at
Mon Jan 21 04:49:23 PST 2008

* Ed Schouten <ed at> wrote:
> It isn't a real problem, because nobody runs TIOCSCTTY on /dev/console
> and pstat(8) only displays some info in that structure, but it should be
> fixed I guess. I'll take a look at this one of these days, but it will
> probably be quite hard for me, because I'm not really familiar with the
> VFS's design.

Ah, I guess I figured it out. It doesn't happen on systems where moused
isn't running. moused opens /dev/consolectl on startup and leaves it
open during its lifetime. When cnclose() calls vn_close(), it won't run
the TTY's close routine because /dev/consolectl is used multiple times.

This means that when a TTY is opened by multiple processes (quite
common), the session will be unset when all users are gone, not when
session itself is being released. This could cause scary things, for
example in ttymodem() when a SIGHUP is sent to the session leader.

This could be fixed by adding a ttysessrel(), which basically performs a
ttyrel(), but also unsets the t_session. I'll take a look at this next
month, when I'll be working on FreeBSD full-time. :-)

 Ed Schouten <ed at>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url :

More information about the freebsd-current mailing list