View | Details | Raw Unified | Return to bug 1140081
Collapse All | Expand All

(-)a/src/login/logind-session.c (-14 / +21 lines)
Lines 1240-1262 error: Link Here
1240
}
1240
}
1241
1241
1242
static void session_restore_vt(Session *s) {
1242
static void session_restore_vt(Session *s) {
1243
        int r, vt, old_fd;
1243
        int r;
1244
1244
1245
        /* We need to get a fresh handle to the virtual terminal,
1245
        r = vt_restore(s->vtfd);
1246
         * since the old file-descriptor is potentially in a hung-up
1246
        if (r == -EIO) {
1247
         * state after the controlling process exited; we do a
1247
                int vt, old_fd;
1248
         * little dance to avoid having the terminal be available
1249
         * for reuse before we've cleaned it up.
1250
         */
1251
        old_fd = TAKE_FD(s->vtfd);
1252
1248
1253
        vt = session_open_vt(s);
1249
log_error("FOO: First attempt to restore VT failed, retrying a 2nd time with a fresh handle");
1254
        safe_close(old_fd);
1255
1250
1256
        if (vt < 0)
1251
                /* It Might happen if the controlling process exited before we
1257
                return;
1252
                 * finished restoring vt completely and would leave the old
1253
                 * file-descriptor potentially in a hung-up state. In this case
1254
                 * let's retry with a fresh handle to the virtual terminal.
1255
                 *
1256
                 * We do a little dance to avoid having the terminal be
1257
                 * available for reuse before we've cleaned it up. */
1258
1259
                old_fd = TAKE_FD(s->vtfd);
1260
1261
                vt = session_open_vt(s);
1262
                safe_close(old_fd);
1263
1264
                if (vt >= 0)
1265
                        r = vt_restore(vt);
1266
        }
1258
1267
1259
        r = vt_restore(vt);
1260
        if (r < 0)
1268
        if (r < 0)
1261
                log_warning_errno(r, "Failed to restore VT, ignoring: %m");
1269
                log_warning_errno(r, "Failed to restore VT, ignoring: %m");
1262
1270
1263
- 

Return to bug 1140081