From 1871e6465bb774c7603a15c194502d581a259bf6 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 2 Jul 2019 12:57:12 +0200 Subject: [PATCH] start: expose LXC_PID to network hooks too Closes #3066. Signed-off-by: Christian Brauner --- src/lxc/start.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lxc/start.c b/src/lxc/start.c index 335f6d6fc..ad6e1f670 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -1756,6 +1756,14 @@ static int lxc_spawn(struct lxc_handler *handler) goto out_delete_net; } + ret = snprintf(pidstr, 20, "%d", handler->pid); + if (ret < 0 || ret >= 20) + goto out_delete_net; + + ret = setenv("LXC_PID", pidstr, 1); + if (ret < 0) + SYSERROR("Failed to set environment variable: LXC_PID=%s", pidstr); + for (i = 0; i < LXC_NS_MAX; i++) if (handler->ns_on_clone_flags & ns_info[i].clone_flag) INFO("Cloned %s", ns_info[i].flag_name); @@ -1882,14 +1890,6 @@ static int lxc_spawn(struct lxc_handler *handler) } } - ret = snprintf(pidstr, 20, "%d", handler->pid); - if (ret < 0 || ret >= 20) - goto out_delete_net; - - ret = setenv("LXC_PID", pidstr, 1); - if (ret < 0) - SYSERROR("Failed to set environment variable: LXC_PID=%s", pidstr); - /* Run any host-side start hooks */ ret = run_lxc_hooks(name, "start-host", conf, NULL); if (ret < 0) { -- 2.47.2