summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2015-08-18 15:19:05 -0400
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:18:46 +0100
commitb79f7282da05915ac86a02e460cccad41f7b7d0c (patch)
treea862ad8da46a048d9999055418246ef600be8918 /src/login
parent21fa96e9227e2438f44de929ee6787ad32360c16 (diff)
logind: get a fresh file descriptor to clean up a VT
When the controlling process exits, any existing file descriptors for that FD will be marked as hung-up and ioctls on them will file with EIO. To work around this, open a new file descriptor for the VT we want to clean up. Thanks to Ray Strode for help in sorting out the problem and coming up with a fix! https://github.com/systemd/systemd/issues/989
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-session.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 70a93c689..1a5c76b81 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1045,7 +1045,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;