]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: reap child in all cases
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 1 Nov 2017 20:58:24 +0000 (21:58 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 8 Nov 2017 23:58:13 +0000 (00:58 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 7a74eb4b2461a3098b1869a3fb377340d9982ac9..fc1fea23a42d79bc551890dc7e913b1c8e6d6803 100644 (file)
@@ -3607,7 +3607,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;
@@ -3777,10 +3777,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)
@@ -3796,6 +3797,9 @@ on_error:
                close(p[0]);
        close(p[1]);
 
+       if (status < 0)
+               ret = -1;
+
        return ret;
 }
 
@@ -3959,10 +3963,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))