[Bug 285394] sysutils/consolekit2 seems to use wrong tty
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 285394] sysutils/consolekit2 seems to use wrong tty"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Mar 2025 15:35:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285394
--- Comment #23 from Andriy Gapon <avg@FreeBSD.org> ---
(In reply to Andriy Gapon from comment #19)
I finally was able to catch the culprit.
This is what destroys the original /dev/console vnode.
1 15949 vgonel:entry
2025 Mar 25 21:45:33 vgone vnode fffff8000607b540, console rdev by sh (21)
kernel`vgone+0x2f
kernel`devfs_revoke+0x41
kernel`VOP_REVOKE_APV+0x71
kernel`killjobc+0x15a
kernel`exit1+0x707
kernel`0xffffffff808bd00d
kernel`amd64_syscall+0x189
kernel`0xffffffff80c4fbfb
My understanding that this is exit of the rc shell process.
init forks a process that exec-s the shell to run /etc/rc.
The process sets up itself as a session leader and /dev/console as its
controlling terminal (as well as stdin, stdout and stderr).
It does that by calling login_tty() which internally uses setsid() and
tcsetsid() to do the job.
See runcom -> run_script -> execute_script -> open_console in sbin/init/init.c.
I guess that this makes total sense give the nature of /etc/rc.
When a session leader process exits, it revokes its controlling terminal.
That's the standard behavior.
I guess that the idea is that any descendant processes in the session get
disassociated from the terminal.
But in this case, the combination of those two sensible thing means revoking
/dev/console from any process that opened it.
Including daemons that independently opened it like what console-kit-daemon
does.
This also explains why the problem is racy.
It depends on when a DM (such as lightdm for me) is started, how quickly it
asks DBus to active ConsoleKit service versus how quickly the remaining rc
scripts are completed.
So, I things can vary greatly depending on hardware, installed and configured
daemons, etc.
--
You are receiving this mail because:
You are the assignee for the bug.