From 325390e5294b3207d0ca01556f501796538018fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 9 Oct 2013 11:03:39 -0700 Subject: [PATCH] launcher: Don't leak tty file descriptor on launcher destroy --- src/launcher-util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/launcher-util.c b/src/launcher-util.c index 6c28dc3..d90271f 100644 --- a/src/launcher-util.c +++ b/src/launcher-util.c @@ -256,7 +256,11 @@ setup_tty(struct weston_launcher *launcher, int tty) int ret, kd_mode; if (tty == 0) { - launcher->tty = tty; + launcher->tty = dup(tty); + if (launcher->tty == -1) { + weston_log("couldn't dup stdin: %m\n"); + return -1; + } } else { snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty); launcher->tty = open(tty_device, O_RDWR | O_CLOEXEC); @@ -379,5 +383,6 @@ weston_launcher_destroy(struct weston_launcher *launcher) wl_event_source_remove(launcher->vt_source); } + close(launcher->tty); free(launcher); } -- 2.7.4