Removed useless opentty function and moved the sighandler restore to the right place

This commit is contained in:
dlezcano 2008-10-08 14:15:17 +00:00
parent 69437d52ec
commit 536b97f0c8

View File

@ -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;