logind: become the controlling terminal process before restoring VT
Basically when a session ends, logind notices and restores VT_AUTO so the kernel takes back VT-switching over. logind achieves that by watching the process that took control of the session (via the "TakeControl" D-Bus method), aka "the watched process", which can be different from the one that initially opened the VT aka "the terminal controlling process". In this case the terminal controlling process can exit after the watched one did and while logind is restoring the VT. Even if logind took care to re-open the VT in case the VT was already in HUP state, it wasn't enough because the terminal controlling process could have exited right after, leaving the VT in HUP state and in VT_PROCESS mode making further VT-switching impossible. This patch fixes this situation by forcing logind to become the terminal controlling process. Fixes: #9754.
Loading