Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxccontainer: enable daemonized execute #1918

Merged
merged 2 commits into from Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/lxc/lxccontainer.c
Expand Up @@ -842,18 +842,6 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
if (!handler)
return false;

if (useinit) {
TRACE("calling \"lxc_execute\"");
ret = lxc_execute(c->name, argv, 1, handler, c->config_path,
daemonize);
c->error_num = ret;

if (ret != 0)
return false;

return true;
}

/* If no argv was passed in, use lxc.init_cmd if provided in the
* configuration
*/
Expand Down Expand Up @@ -1033,7 +1021,10 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
goto on_error;
}

ret = lxc_start(c->name, argv, handler, c->config_path, daemonize);
if (useinit)
ret = lxc_execute(c->name, argv, 1, handler, c->config_path, daemonize);
else
ret = lxc_start(c->name, argv, handler, c->config_path, daemonize);
c->error_num = ret;

if (conf->reboot == 1) {
Expand Down
7 changes: 6 additions & 1 deletion src/lxc/tools/lxc_execute.c
Expand Up @@ -49,6 +49,9 @@ static struct lxc_list defines;
static int my_parser(struct lxc_arguments* args, int c, char* arg)
{
switch (c) {
case 'd':
args->daemonize = 1;
break;
case 'f':
args->rcfile = arg;
break;
Expand All @@ -67,6 +70,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
}

static const struct option my_longopts[] = {
{"daemon", no_argument, 0, 'd'},
{"rcfile", required_argument, 0, 'f'},
{"define", required_argument, 0, 's'},
{"uid", required_argument, 0, 'u'},
Expand All @@ -90,6 +94,7 @@ Options :\n\
-g, --gid=GID Execute COMMAND with GID inside the container\n",
.options = my_longopts,
.parser = my_parser,
.daemonize = 0,
};

static bool set_argv(struct lxc_conf *conf, struct lxc_arguments *args)
Expand Down Expand Up @@ -180,7 +185,7 @@ int main(int argc, char *argv[])
if (my_args.gid)
c->lxc_conf->init_gid = my_args.gid;

c->daemonize = false;
c->daemonize = my_args.daemonize == 1;
bret = c->start(c, 1, my_args.argv);
ret = c->error_num;
lxc_container_put(c);
Expand Down