]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Pass the ttyname to the lxc_setup function
authordlezcano <dlezcano>
Tue, 25 Nov 2008 13:00:49 +0000 (13:00 +0000)
committerdlezcano <dlezcano>
Tue, 25 Nov 2008 13:00:49 +0000 (13:00 +0000)
From: Daniel Lezcano <dlezcano@fr.ibm.com>

Retrieve the ttyname and pass it to the lxc_setup function.

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

index 3032da7b8805cef1899ba1fe846426689dc87036..b4839a6cdea518d9f5282dd9be2fe9efbd1f0ed5 100644 (file)
@@ -48,6 +48,7 @@ LXC_TTY_HANDLER(SIGQUIT);
 int lxc_start(const char *name, char *argv[])
 {
        char init[MAXPATHLEN];
+       char tty[MAXPATHLEN];
        char *val = NULL;
        int fd, lock, sv[2], sync = 0, err = -LXC_ERROR_INTERNAL;
        pid_t pid;
@@ -69,6 +70,11 @@ int lxc_start(const char *name, char *argv[])
                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");
@@ -112,7 +118,7 @@ int lxc_start(const char *name, char *argv[])
                }
 
                /* Setup the container, ip, names, utsname, ... */
-               err = lxc_setup(name);
+               err = lxc_setup(name, tty);
                if (err) {
                        lxc_log_error("failed to setup the container");
                        if (write(sv[0], &err, sizeof(err)) < 0)
@@ -207,10 +213,8 @@ wait_again:
        if (lxc_setstate(name, STOPPING))
                lxc_log_error("failed to set state %s", lxc_state2str(STOPPING));
 
-#ifdef NETWORK_DESTROY
        if (clone_flags & CLONE_NEWNET && conf_destroy_network(name))
                lxc_log_error("failed to destroy the network");
-#endif
 
        err = 0;
 out:
@@ -233,10 +237,8 @@ err_state_failed:
 err_child_failed:
 err_pipe_read2:
 err_pipe_write:
-#ifdef NETWORK_DESTROY
        if (clone_flags & CLONE_NEWNET)
                conf_destroy_network(name);
-#endif
 err_create_network:
 err_pipe_read:
 err_waitpid_failed: