]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Allow daemonizing CPU resource managers
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 15 Oct 2010 06:14:46 +0000 (08:14 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 15 Oct 2010 06:14:46 +0000 (08:14 +0200)
resources/cpu_aquosa/mngr/frm_aqcpu.c
resources/cpucg/mngr/frm_cgcpu.c

index fe657590c5126fa3a07f9ef93290ec7d76009d10..381ad70ad6b6aae5a8ec38f428303f875dccb29d 100644 (file)
@@ -116,6 +116,7 @@ static void
 usage(void)
 {
        printf("usage: frm_aqcpu [ options ]\n");
+       printf("  -d, --daemon [pid-file]   go to background after FORB initialization\n");
        printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
 }
 
@@ -125,11 +126,17 @@ int main(int argc, char *argv[])
        int ret;
        forb_init_attr_t attr = { .orb_id = "org.frescor.frm.aqcpu" };
        int  opt;
+       bool opt_daemon = false;
+       char *opt_pidfile = NULL;
 
        ul_logreg_domain(&ulogd_frm_aqcpu);
 
-       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "d::hl:", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
+                       case 'd':
+                               opt_daemon = true;
+                               opt_pidfile = optarg;
+                               break;
                        case 'l':
                                ul_log_domain_arg2levels(optarg);
                                break;
@@ -140,6 +147,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");
 
index 57d01195c680b902c843acd83fad6a76621c6491..f9c288b0e67fa5d0105573c0e6347957962e5610 100644 (file)
@@ -134,11 +134,17 @@ int main(int argc, char *argv[])
        int ret;
        int  opt;
        forb_init_attr_t attr = { .orb_id = "org.frescor.frm.cgcpu" };
+       bool opt_daemon = false;
+       char *opt_pidfile = NULL;
 
        ul_logreg_domain(&ulogd_frm_cpucg);
 
-       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "d::hl:", &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");