From: Christian Brauner Date: Wed, 1 Nov 2017 20:58:24 +0000 (+0100) Subject: conf: reap child in all cases X-Git-Tag: lxc-2.0.10~599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f586ee97056bff3fcfbfd588c37aed6a0376125;p=thirdparty%2Flxc.git conf: reap child in all cases Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index d55483df6..133bba681 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -3602,7 +3602,7 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data, struct lxc_list *it; struct id_map *map; char c = '1'; - int ret = -1; + int ret = -1, status = -1; struct lxc_list *idmap = NULL, *tmplist = NULL; struct id_map *container_root_uid = NULL, *container_root_gid = NULL, *host_uid_map = NULL, *host_gid_map = NULL; @@ -3772,10 +3772,11 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data, goto on_error; } +on_error: /* Wait for child to finish. */ - ret = wait_for_pid(pid); + if (pid > 0) + status = wait_for_pid(pid); -on_error: if (idmap) lxc_free_idmap(idmap); if (container_root_uid) @@ -3791,6 +3792,9 @@ on_error: close(p[0]); close(p[1]); + if (status < 0) + ret = -1; + return ret; } @@ -3954,10 +3958,11 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data, goto on_error; } +on_error: /* Wait for child to finish. */ - ret = wait_for_pid(pid); + if (pid > 0) + ret = wait_for_pid(pid); -on_error: if (idmap) lxc_free_idmap(idmap); if (host_uid_map && (host_uid_map != container_root_uid))