From 4c35326fd6e30b310662a354e6c134baf1647d76 Mon Sep 17 00:00:00 2001 From: Petr Benes Date: Thu, 17 Feb 2011 16:59:16 +0100 Subject: [PATCH] forb: fixed passing parameters to shared libraries in forbrun --- src/forb/src/forbrun/forbrun.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/forb/src/forbrun/forbrun.c b/src/forb/src/forbrun/forbrun.c index 1f1d4721..08f33395 100644 --- a/src/forb/src/forbrun/forbrun.c +++ b/src/forb/src/forbrun/forbrun.c @@ -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; } -- 2.39.2