</refsect1>
+ <refsect1>
+
+ <title>Options</title>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <option>-d, --daemon</option>
+ </term>
+ <listitem>
+ <para>
+ Run the container as a daemon. As the container has no
+ more tty, if an error occurs nothing will be displayed,
+ the log file can be used to check the error.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </refsect1>
+
&commonoptions;
<refsect1>
</listitem>
</varlistentry>
-
</variablelist>
</refsect1>
#include <string.h>
#include <termios.h>
#include <errno.h>
+#include <fcntl.h>
#include <signal.h>
#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <net/if.h>
lxc_log_define(lxc_start, lxc);
+static int my_parser(struct lxc_arguments* args, int c, char* arg)
+{
+ switch (c) {
+ case 'd': args->daemonize = 1; break;
+ }
+ return 0;
+}
+
static const struct option my_longopts[] = {
+ {"daemon", no_argument, 0, 'd'},
LXC_COMMON_OPTIONS
};
lxc-start start COMMAND in specified container NAME\n\
\n\
Options :\n\
- -n, --name=NAME NAME for name of the container",
- .options = my_longopts,
- .parser = NULL,
- .checker = NULL,
+ -n, --name=NAME NAME for name of the container\n\
+ -d, --daemon daemonize the container",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+ .daemonize = 0,
};
static int save_tty(struct termios *tios)
my_args.progname, my_args.quiet))
return err;
+ if (my_args.daemonize && daemon(0 ,0)) {
+ SYSERROR("failed to daemonize '%s'", my_args.name);
+ return err;
+ }
+
save_tty(&tios);
err = lxc_start(my_args.name, args);