swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit dd0b21656eb7b19e8e6f454ab0de4284998d47f5
parent 9643dcb61ee2c7483afbf94ca9976557089936c8
Author: Michael Forney <mforney@mforney.org>
Date:   Tue,  5 Aug 2014 19:45:06 -0700

launch: Stop devices *before* activating old VT

Otherwise, if there is a display server running on the old VT, it may
try to acquire DRM master before we have released it.

Diffstat:
Mlaunch/launch.c | 23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/launch/launch.c b/launch/launch.c @@ -121,19 +121,21 @@ static void stop_devices(bool fatal) static void cleanup() { - /* Cleanup VT */ - if (original_vt_state.altered) - { - struct vt_mode mode = { .mode = VT_AUTO }; + struct vt_mode mode = { .mode = VT_AUTO }; - fprintf(stderr, "Restoring VT to original state\n"); - ioctl(launcher.tty_fd, VT_SETMODE, &mode); - ioctl(launcher.tty_fd, KDSETMODE, original_vt_state.console_mode); - ioctl(launcher.tty_fd, KDSKBMODE, original_vt_state.kb_mode); - ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt); - } + if (!original_vt_state.altered) + return; + /* Cleanup VT */ + fprintf(stderr, "Restoring VT to original state\n"); + ioctl(launcher.tty_fd, VT_SETMODE, &mode); + ioctl(launcher.tty_fd, KDSETMODE, original_vt_state.console_mode); + ioctl(launcher.tty_fd, KDSKBMODE, original_vt_state.kb_mode); + + /* Stop devices before switching the VT to make sure we have released the + * DRM device before the next session tries to claim it. */ stop_devices(false); + ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt); } void __attribute__((noreturn,format(printf,1,2))) @@ -317,7 +319,6 @@ static int find_vt() die("Could not find unused VT"); close(tty0_fd); - fprintf(stderr, "Running on VT %d\n", vt); done: