openvt: set the session controlling terminal
authorAlexey Gladkov <legion@altlinux.org>
Mon, 21 May 2007 08:08:44 +0000 (12:08 +0400)
committerAlexey Gladkov <legion@altlinux.org>
Mon, 21 May 2007 08:23:49 +0000 (12:23 +0400)
Signed-off-by: Alexey Gladkov <legion@altlinux.org>
openvt/openvt.c
src/getfd.c

index b830a4d854ff4e400cfcee7b2fe7cb2eb2da1ddf..886ed723fc2a09331eecd21972ce7abab74d9b87 100644 (file)
@@ -272,6 +272,12 @@ got_vtno:
        _exit (1);
       }
 
+      if (ioctl(fd1, TIOCSCTTY, (char *)1)) {
+       perror("ioctl TIOCSCTTY");
+       fflush(stderr);
+       _exit (1);
+      }
+
       /* slight problem: after "openvt -su" has finished, the
         utmp entry is not removed */
       if(as_user)
index e0860a107998d5e730d0543f114754812d99512b..572e5de44956b2e56ccb567409792ac2dc8c6dcf 100644 (file)
@@ -34,9 +34,9 @@ open_a_console(const char *fnam) {
         * do not matter. But setfont:activatemap() does a write.
         */
        fd = open(fnam, O_RDWR);
-       if (fd < 0 && errno == EACCES)
+       if (fd < 0)
                fd = open(fnam, O_WRONLY);
-       if (fd < 0 && errno == EACCES)
+       if (fd < 0)
                fd = open(fnam, O_RDONLY);
        if (fd < 0)
                return -1;