]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Removed useless opentty function and moved the sighandler restore to the right place
authordlezcano <dlezcano>
Wed, 8 Oct 2008 14:15:17 +0000 (14:15 +0000)
committerdlezcano <dlezcano>
Wed, 8 Oct 2008 14:15:17 +0000 (14:15 +0000)
src/lxc/start.c

index 5e95009eaa1cea47123f1381a4510a005bb7ab7a..ad6f7a647e94ecbd895d8ef361400e5ef6665b4d 100644 (file)
 LXC_TTY_HANDLER(SIGINT);
 LXC_TTY_HANDLER(SIGQUIT);
 
-int opentty(const char *ttyname)
-{
-        int i, fd, flags;
-
-        fd = open(ttyname, O_RDWR | O_NONBLOCK);
-        if (fd == -1) {
-               lxc_log_syserror("open '%s'", ttyname);
-               return -1;
-        }
-
-        flags = fcntl(fd, F_GETFL);
-        flags &= ~O_NONBLOCK;
-        fcntl(fd, F_SETFL, flags);
-
-        for (i = 0; i < fd; i++)
-                close(i);
-        for (i = 0; i < 3; i++)
-                if (fd != i)
-                        dup2(fd, i);
-        if (fd >= 3)
-                close(fd);
-
-       return 0;
-}
-
 int lxc_start(const char *name, int argc, char *argv[], 
              lxc_callback_t prestart, void *data)
 {
@@ -151,12 +126,6 @@ int lxc_start(const char *name, int argc, char *argv[],
                        return -1;
                }
 
-               /* Open the tty */
-               if (opentty(ttyname)) {
-                       lxc_log_syserror("failed to open the tty");
-                       return -1;
-               }
-
                if (mount(ttyname, "/dev/console", "none", MS_BIND, 0)) {
                        lxc_log_syserror("failed to mount '/dev/console'");
                        return -1;
@@ -262,6 +231,8 @@ out:
        unlink(init);
        free(val);
        lxc_put_lock(lock);
+       LXC_TTY_DEL_HANDLER(SIGQUIT);
+       LXC_TTY_DEL_HANDLER(SIGINT);
 
        return err;
 
@@ -282,8 +253,6 @@ err_waitpid_failed:
 
        kill(pid, SIGKILL);
 err_fork_ns:
-       LXC_TTY_DEL_HANDLER(SIGQUIT);
-       LXC_TTY_DEL_HANDLER(SIGINT);
        close(sv[0]);
        close(sv[1]);
        goto out;