]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
forb: fixed passing parameters to shared libraries in forbrun
authorPetr Benes <benesp16@fel.cvut.cz>
Thu, 17 Feb 2011 15:59:16 +0000 (16:59 +0100)
committerPetr Benes <benesp16@fel.cvut.cz>
Thu, 17 Feb 2011 15:59:16 +0000 (16:59 +0100)
src/forbrun/forbrun.c

index 1f1d47216505fa3a8c7fc6ca1367d218bb7261e7..08f33395731402832b94275b89d1eee9f5217e4c 100644 (file)
@@ -53,6 +53,7 @@ void *forb_main_thread(void *arg)
 
 int main(int argc, char *argv[])
 {
+       unsigned libs_loaded_cnt = 0;
        forb_orb orb;
        bool opt_daemon = false;
        char *opt_pidfile = NULL;
@@ -69,7 +70,7 @@ int main(int argc, char *argv[])
        };
        int  opt;
 
-       while ((opt = getopt_long(argc, argv, "d::hil:p:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "d::hil:p:x", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
 #if 0                  
                        case 'l':
@@ -109,6 +110,7 @@ int main(int argc, char *argv[])
        orb = forb_init(&argc, &argv, &attr);
        if (!orb) error(1, errno, "FORB initialization failed");
 
+
 #if CONFIG_FCB_INET && !CONFIG_FORB_PROTO_INET_DEFAULT
        ret = register_inet_port(orb);
        if (ret) error(0, errno, "INET port registration failed");
@@ -128,9 +130,19 @@ int main(int argc, char *argv[])
                        error(1, errno, "Cannot find forb_main() in %s", data.filename);
 
                data.orb = orb;
-               data.argc = 0;  /* TODO argc and argv after "--" */
-               data.argv = NULL; /* TODO argc and argv after "--" */
+               
+               // parse forb parameters
+               data.argc = 1;
+               data.argv = &argv[i];
+               while (i+1 < argc) {
+                       i++;
+                       if (!strcmp(argv[i], "--")) 
+                               break;
+                       else
+                               data.argc++;
+               }
                fosa_thread_create(&tid, NULL, forb_main_thread, &data);
+               libs_loaded_cnt++;
 
                forb_wait_for_server_ready(orb);
        }
@@ -140,7 +152,8 @@ int main(int argc, char *argv[])
 
        /* Allow other threads to continue execution, but exit
         * ourselves (without exit()ing the whole process. */
-       pthread_exit(NULL);     
+       if (libs_loaded_cnt > 0)
+               pthread_exit(NULL);     
 
        return 0;
 }