]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: add "--daemonize/-d" 1918/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 10 Nov 2017 23:22:09 +0000 (00:22 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 10 Nov 2017 23:22:09 +0000 (00:22 +0100)
This lets's users run daemonized application containers with our minimal init
as pid 1 and the requested program as pid 2.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/tools/lxc_execute.c

index 8a34e1f45c6c5cede84aff74901d6c5c3aa73107..2faeed948d46faf7438ff51b6e8b7560c68b1113 100644 (file)
@@ -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;
@@ -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'},
@@ -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)
@@ -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);