]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
wait_on_damonized-start: wait only on the pid we want
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 8 Nov 2013 17:41:16 +0000 (17:41 +0000)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 8 Nov 2013 19:31:51 +0000 (13:31 -0600)
Otherwise we can reap another thread's forked pid.

Changelog: Per Dwight's suggestion, use pid_t for argument.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
src/lxc/lxccontainer.c

index 827cae0a6d14c698f649bcff8036890308534c19..ede011324ac916adf14606b108607a6aa27964f5 100644 (file)
@@ -491,7 +491,7 @@ static bool lxcapi_wait(struct lxc_container *c, const char *state, int timeout)
 }
 
 
-static bool wait_on_daemonized_start(struct lxc_container *c)
+static bool wait_on_daemonized_start(struct lxc_container *c, int pid)
 {
        /* we'll probably want to make this timeout configurable? */
        int timeout = 5, ret, status;
@@ -500,7 +500,7 @@ static bool wait_on_daemonized_start(struct lxc_container *c)
         * our child is going to fork again, then exit.  reap the
         * child
         */
-       ret = wait(&status);
+       ret = waitpid(pid, &status, 0);
        if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
                DEBUG("failed waiting for first dual-fork child");
        return lxcapi_wait(c, "RUNNING", timeout);
@@ -607,7 +607,7 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
                        return false;
                }
                if (pid != 0)
-                       return wait_on_daemonized_start(c);
+                       return wait_on_daemonized_start(c, pid);
 
                process_unlock(); // we're no longer sharing
                /* second fork to be reparented by init */