[PATCH] tty: fix initialisation failure cleanup

Rafal Mielniczuk rafal.mielniczuk2 at gmail.com
Sun May 20 04:47:28 PDT 2012


This patch sets mode back to VT_AUTO and restores original terminal
in error handling routines
---
 src/tty.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/tty.c b/src/tty.c
index 78d5ba5..72d271a 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -237,6 +237,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func,
 	return tty;
 
 err_vtmode:
+	mode.mode = VT_AUTO;
 	ioctl(tty->fd, VT_SETMODE, &mode);
 
 err_kdmode:
@@ -251,6 +252,10 @@ err_attr:
 	tcsetattr(tty->fd, TCSANOW, &tty->terminal_attributes);
 
 err:
+	if (tty->has_vt && tty->vt != tty->starting_vt) {
+		ioctl(tty->fd, VT_ACTIVATE, tty->starting_vt);
+		ioctl(tty->fd, VT_WAITACTIVE, tty->starting_vt);
+	}
 	close(tty->fd);
 	free(tty);
 	return NULL;
-- 
1.7.10.2



More information about the wayland-devel mailing list