overlay: Detach from terminal
authorChris Wilson <chris@chris-wilson.co.uk>
Sun, 25 Aug 2013 14:17:39 +0000 (15:17 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sun, 25 Aug 2013 14:18:39 +0000 (15:18 +0100)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
overlay/overlay.c

index a1d21df..67c4a86 100644 (file)
@@ -734,12 +734,13 @@ int main(int argc, char **argv)
        struct overlay_context ctx;
        struct config config;
        int index, sample_period;
+       int daemonize = 1;
        int i;
 
        config_init(&config);
 
        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) {
                case 'c':
                        config_parse_string(&config, optarg);
@@ -750,6 +751,9 @@ int main(int argc, char **argv)
                case 'P':
                        config_set_value(&config, "window", "position", optarg);
                        break;
+               case 'f':
+                       daemonize = 0;
+                       break;
                }
        }
 
@@ -770,6 +774,9 @@ int main(int argc, char **argv)
        if (ctx.surface == NULL)
                return ENOMEM;
 
+       if (daemonize && daemon(0, 0))
+               return EINVAL;
+
        signal(SIGUSR1, signal_snapshot);
 
        debugfs_init();