overlay: Detach from terminal

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-25 15:17:39 +01:00
parent d929102591
commit 39f9812315

View File

@ -734,12 +734,13 @@ int main(int argc, char **argv)
struct overlay_context ctx; struct overlay_context ctx;
struct config config; struct config config;
int index, sample_period; int index, sample_period;
int daemonize = 1;
int i; int i;
config_init(&config); config_init(&config);
opterr = 0; opterr = 0;
while ((i = getopt_long(argc, argv, "c:", long_options, &index)) != -1) { while ((i = getopt_long(argc, argv, "c:f", long_options, &index)) != -1) {
switch (i) { switch (i) {
case 'c': case 'c':
config_parse_string(&config, optarg); config_parse_string(&config, optarg);
@ -750,6 +751,9 @@ int main(int argc, char **argv)
case 'P': case 'P':
config_set_value(&config, "window", "position", optarg); config_set_value(&config, "window", "position", optarg);
break; break;
case 'f':
daemonize = 0;
break;
} }
} }
@ -770,6 +774,9 @@ int main(int argc, char **argv)
if (ctx.surface == NULL) if (ctx.surface == NULL)
return ENOMEM; return ENOMEM;
if (daemonize && daemon(0, 0))
return EINVAL;
signal(SIGUSR1, signal_snapshot); signal(SIGUSR1, signal_snapshot);
debugfs_init(); debugfs_init();