]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Allow daemonizing FWP manager
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 15 Oct 2010 06:15:02 +0000 (08:15 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 15 Oct 2010 06:15:02 +0000 (08:15 +0200)
fwp/mngr/fwp_mngr.c

index aa2d8505338848c420c9368d3c716cf95322f9e1..233215ddff03db9b9bae0f8962b36a021507935f 100644 (file)
@@ -123,13 +123,19 @@ int main(int argc, char *argv[])
        int ret;
        forb_init_attr_t attr = { .orb_id = "org.frescor.frm.fwp" };
        int  opt;
+       bool opt_daemon = false;
+       char *opt_pidfile = NULL;
 
        if (getenv("FWP_BYPASS"))
                priv.bypass = true;
 
 
-       while ((opt = getopt_long(argc, argv, "b:l:os", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "b:l:hos", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
+                       case 'd':
+                               opt_daemon = true;
+                               opt_pidfile = optarg;
+                               break;
                        case 'l':
                                ul_log_domain_arg2levels(optarg);
                                break;
@@ -149,6 +155,9 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (opt_daemon)
+               forb_daemon_prepare(opt_pidfile);
+
        orb = forb_init(&argc, &argv, &attr);
        if (!orb) error(1, errno, "forb_init");