From: Christian Brauner Date: Fri, 29 Jan 2021 12:14:37 +0000 (+0100) Subject: attach: move attach_clone_payload into tighter scope X-Git-Tag: lxc-5.0.0~313^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a64902abe36e160f6889a14ce9c156ed491bc9c1;p=thirdparty%2Flxc.git attach: move attach_clone_payload into tighter scope Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index adc9b4088..ca7348d93 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1031,7 +1031,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, pid_t *attached_process) { int ret_parent = -1; - struct attach_clone_payload payload = {}; struct lxc_epoll_descr descr = {}; int i, ret, status; char *name, *lxcpath, *new_cwd; @@ -1225,13 +1224,6 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, free_disarm(cwd); /* Create attached process. */ - payload.ipc_socket = ipc_sockets[1]; - payload.options = options; - payload.ctx = ctx; - payload.terminal_pts_fd = terminal.pty; - payload.exec_function = exec_function; - payload.exec_payload = exec_payload; - pid = lxc_raw_clone(CLONE_PARENT, NULL); if (pid < 0) { SYSERROR("Failed to clone attached process"); @@ -1241,6 +1233,15 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, } if (pid == 0) { + struct attach_clone_payload payload = { + .ipc_socket = ipc_sockets[1], + .options = options, + .ctx = ctx, + .terminal_pts_fd = terminal.pty, + .exec_function = exec_function, + .exec_payload = exec_payload, + }; + if (options->attach_flags & LXC_ATTACH_TERMINAL) { ret = lxc_terminal_signal_sigmask_safe_blocked(&terminal); if (ret < 0) { @@ -1249,6 +1250,7 @@ int lxc_attach(struct lxc_container *container, lxc_attach_exec_t exec_function, } } + /* Does not return. */ do_attach(&payload); }