From 939229eb160b30bd5c6c7765efed314feba99da3 Mon Sep 17 00:00:00 2001 From: dlezcano Date: Tue, 25 Nov 2008 13:00:49 +0000 Subject: [PATCH] Pass the ttyname to the lxc_setup function From: Daniel Lezcano Retrieve the ttyname and pass it to the lxc_setup function. Signed-off-by: Daniel Lezcano --- src/lxc/start.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index 3032da7b8..b4839a6cd 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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: -- 2.39.5