From: dlezcano Date: Wed, 8 Oct 2008 14:15:17 +0000 (+0000) Subject: Removed useless opentty function and moved the sighandler restore to the right place X-Git-Tag: lxc_0_4_0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=536b97f0c854d3ad8e9645bbd5571b52d83693f4;p=thirdparty%2Flxc.git Removed useless opentty function and moved the sighandler restore to the right place --- diff --git a/src/lxc/start.c b/src/lxc/start.c index 5e95009ea..ad6f7a647 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -42,31 +42,6 @@ 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;