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=30380ae52f9426f69154da98cd40787f3112676f;hb=b79f7282da05915ac86a02e460cccad41f7b7d0c;hpb=b5132cc290ef609fb7a84adb8130526fb433c291 diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 30380ae52..1a5c76b81 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -513,7 +513,7 @@ static int session_start_scope(Session *s) { if (!scope) return log_oom(); - r = manager_start_scope(s->manager, scope, s->leader, s->user->slice, description, "logind.service", "systemd-user-sessions.service", &error, &job); + r = manager_start_scope(s->manager, scope, s->leader, s->user->slice, description, "systemd-logind.service", "systemd-user-sessions.service", &error, &job); if (r < 0) { log_error("Failed to start session scope %s: %s %s", scope, bus_error_message(&error, r), error.name); @@ -981,7 +981,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); @@ -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;