From aaa5b82e613739723714e859930aeec02b50af6a Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 14 Nov 2019 22:07:27 +0100 Subject: [PATCH] weston-launch: do not close tty prematurely The tty file descriptor is used in signal handling (when switching VT via SIGUSR1/SIGUSR2 for the VT_RELDISP ioctrl) and in quit() when weston-launch exits for the KDSKBMUTE/KDSKBMODE/KDSETMODE/VT_SETMODE ioctrls. This fixes VT switching when using weston-launch from a non-VT shell (e.g. ssh or from within a container). Signed-off-by: Stefan Agner --- libweston/weston-launch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c index 8a711b4a..8d1aa39e 100644 --- a/libweston/weston-launch.c +++ b/libweston/weston-launch.c @@ -457,6 +457,9 @@ quit(struct weston_launch *wl, int status) if (ioctl(wl->tty, VT_SETMODE, &mode) < 0) fprintf(stderr, "could not reset vt handling\n"); + if (wl->tty != STDIN_FILENO) + close(wl->tty); + exit(status); } @@ -847,8 +850,6 @@ main(int argc, char *argv[]) launch_compositor(&wl, argc - optind, argv + optind); close(wl.sock[1]); - if (wl.tty != STDIN_FILENO) - close(wl.tty); while (1) { struct pollfd fds[2];