Skip to content

Commit

Permalink
lxccontainer: remove PID file after lxc_start return
Browse files Browse the repository at this point in the history
Make the way symmetric. This also fix the file leak in
daemon model.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
hqhq authored and stgraber committed Jan 26, 2014
1 parent a684f0b commit 487d800
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lxc/lxccontainer.c
Expand Up @@ -233,11 +233,6 @@ static void lxc_container_free(struct lxc_container *c)
free(c->config_path);
c->config_path = NULL;
}
if (c->pidfile) {
unlink(c->pidfile);
free(c->pidfile);
c->pidfile = NULL;
}

free(c);
}
Expand Down Expand Up @@ -665,6 +660,12 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
goto reboot;
}

if (c->pidfile) {
unlink(c->pidfile);
free(c->pidfile);
c->pidfile = NULL;
}

if (daemonize)
exit (ret == 0 ? true : false);
else
Expand Down

0 comments on commit 487d800

Please sign in to comment.