]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Remove annoying warnings and fix tty for restart
authordlezcano <dlezcano>
Wed, 26 Nov 2008 17:05:11 +0000 (17:05 +0000)
committerdlezcano <dlezcano>
Wed, 26 Nov 2008 17:05:11 +0000 (17:05 +0000)
From: Daniel Lezcano <dlezcano@fr.ibm.com>

Remove annoying compilation messages and fix tty for the restart.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/destroy.c
src/lxc/restart.c
src/lxc/start.c

index 1834795eaf98bca7210c2b97042e2351d1612909..01b4b43112f44444237d22fa7c7418d7e8799d5c 100644 (file)
@@ -83,6 +83,5 @@ int lxc_destroy(const char *name)
        
 out_lock:
        lxc_put_lock(lock);
-out:
        return ret;
 }
index 28a58d89b7cd9a572ebcb06efe6814e4fe9a0e8f..38ba092c506d6f24eb72701688fef65c83d9ca8b 100644 (file)
@@ -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;
 }
index b4839a6cdea518d9f5282dd9be2fe9efbd1f0ed5..c539fa94e8c278ec30f22c9546d9ecebd503740e 100644 (file)
@@ -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)) {