From: dlezcano Date: Wed, 26 Nov 2008 17:05:11 +0000 (+0000) Subject: Remove annoying warnings and fix tty for restart X-Git-Tag: lxc_0_5_0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=caf249f40ed750d8e1375c7b41f16cbdeef87eb2;p=thirdparty%2Flxc.git Remove annoying warnings and fix tty for restart From: Daniel Lezcano Remove annoying compilation messages and fix tty for the restart. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/destroy.c b/src/lxc/destroy.c index 1834795ea..01b4b4311 100644 --- a/src/lxc/destroy.c +++ b/src/lxc/destroy.c @@ -83,6 +83,5 @@ int lxc_destroy(const char *name) out_lock: lxc_put_lock(lock); -out: return ret; } diff --git a/src/lxc/restart.c b/src/lxc/restart.c index 28a58d89b..38ba092c5 100644 --- a/src/lxc/restart.c +++ b/src/lxc/restart.c @@ -48,7 +48,7 @@ int lxc_restart(const char *name, const char *statefile, unsigned long flags) { char *init = NULL, *val = NULL; - char ttyname[MAXPATHLEN]; + char tty[MAXPATHLEN]; int fd, lock, sv[2], sync = 0, err = -1; pid_t pid; int clone_flags; @@ -65,12 +65,11 @@ int lxc_restart(const char *name, const char *statefile, goto out; } - if (readlink("/proc/self/fd/0", ttyname, sizeof(ttyname)) < 0) { - lxc_log_syserror("failed to read '/proc/self/fd/0'"); - goto out; + if (ttyname_r(0, tty, sizeof(tty))) { + tty[0] = '\0'; + lxc_log_warning("failed to get tty name"); } - /* Synchro socketpair */ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) { lxc_log_syserror("failed to create communication socketpair"); @@ -96,7 +95,6 @@ int lxc_restart(const char *name, const char *statefile, if (!pid) { - char dummytty = '\0'; close(sv[1]); /* Be sure we don't inherit this after the exec */ @@ -115,18 +113,13 @@ int lxc_restart(const char *name, const char *statefile, } /* Setup the container, ip, names, utsname, ... */ - if (lxc_setup(name, &dummytty)) { + if (lxc_setup(name, tty)) { lxc_log_error("failed to setup the container"); if (write(sv[0], &sync, sizeof(sync)) < 0) lxc_log_syserror("failed to write the socket"); return -1; } - if (mount(ttyname, "/dev/console", "none", MS_BIND, 0)) { - lxc_log_syserror("failed to mount '/dev/console'"); - return -1; - } - lxc_plugin_restart(getpid(), statefile, flags); lxc_log_syserror("failed to restart"); @@ -243,6 +236,5 @@ err_fork_ns: LXC_TTY_DEL_HANDLER(SIGINT); close(sv[0]); close(sv[1]); -err: goto out; } diff --git a/src/lxc/start.c b/src/lxc/start.c index b4839a6cd..c539fa94e 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -70,10 +70,9 @@ int lxc_start(const char *name, char *argv[]) goto out; } - if (ttyname_r(0, tty, sizeof(tty))) { + /* If we are not attached to a tty, disable it */ + if (ttyname_r(0, tty, sizeof(tty))) tty[0] = '\0'; - lxc_log_warning("failed to get tty name"); - } /* Synchro socketpair */ if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) {