From: Christian Brauner Date: Tue, 2 Jul 2019 10:57:12 +0000 (+0200) Subject: start: expose LXC_PID to network hooks too X-Git-Tag: lxc-3.2.0~17^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1871e6465bb774c7603a15c194502d581a259bf6;p=thirdparty%2Flxc.git start: expose LXC_PID to network hooks too Closes #3066. Signed-off-by: Christian Brauner --- 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) {