launcher: Don't leak tty file descriptor on launcher destroy

dev
Kristian Høgsberg 11 years ago
parent 8ac6a2da07
commit 325390e529
  1. 7
      src/launcher-util.c

@ -256,7 +256,11 @@ setup_tty(struct weston_launcher *launcher, int tty)
int ret, kd_mode; int ret, kd_mode;
if (tty == 0) { 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 { } else {
snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty); snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty);
launcher->tty = open(tty_device, O_RDWR | O_CLOEXEC); 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); wl_event_source_remove(launcher->vt_source);
} }
close(launcher->tty);
free(launcher); free(launcher);
} }

Loading…
Cancel
Save