summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2015-08-19 16:40:54 +0200
committerDavid Herrmann <dh.herrmann@googlemail.com>2015-08-19 16:40:54 +0200
commit2c04e5c7e530484df1ce9e3d4be609cb1670a99a (patch)
tree4ac106c8bed1b500fca91bf383fec9ccf15af71e /src
parent9a8e6b02140d411b2b6699187c9a8ed00075942d (diff)
parent128df4cfe93e6de6afb38a2160167339d88f4e1a (diff)
Merge pull request #990 from owtaylor/issue-989
Issue 989 - logind: VT is not properly reset on session close
Diffstat (limited to 'src')
-rw-r--r--src/login/logind-session.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index e75c7c042e..92a6027a7e 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -986,7 +986,7 @@ static int session_open_vt(Session *s) {
return s->vtfd;
sprintf(path, "/dev/tty%u", s->vtnr);
- s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
+ s->vtfd = open_terminal(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
if (s->vtfd < 0)
return log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id);
@@ -1050,7 +1050,18 @@ void session_restore_vt(Session *s) {
int vt, kb = K_XLATE;
struct vt_mode mode = { 0 };
+ /* We need to get a fresh handle to the virtual terminal,
+ * since the old file-descriptor is potentially in a hung-up
+ * state after the controlling process exited; we do a
+ * little dance to avoid having the terminal be available
+ * for reuse before we've cleaned it up.
+ */
+ int old_fd = s->vtfd;
+ s->vtfd = -1;
+
vt = session_open_vt(s);
+ safe_close(old_fd);
+
if (vt < 0)
return;