X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-session.c;h=1a5c76b815f4811a12e995fe89778a6e1fed4c3f;hp=70a93c689691438e188ec1838c1225bab71ca28a;hb=b79f7282da05915ac86a02e460cccad41f7b7d0c;hpb=21fa96e9227e2438f44de929ee6787ad32360c16 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;