Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2025 15:35:09 +0000
From:      bugzilla-noreply@freebsd.org
To:        desktop@FreeBSD.org
Subject:   [Bug 285394] sysutils/consolekit2 seems to use wrong tty
Message-ID:  <bug-285394-39348-0P3U9mNRza@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-285394-39348@https.bugs.freebsd.org/bugzilla/>
References:  <bug-285394-39348@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D285394

--- 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/ini=
t.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 configur=
ed
daemons, etc.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-285394-39348-0P3U9mNRza>