X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-launch.c;h=839194340389e7f8e2c1bb9489cfb59246c6f43e;hb=6f6d04fef9f08d756a37d17333f5b9b9a6b72dd2;hp=87c5b12295cac9c5985127de492e3aa21e151a03;hpb=2c6fcae14552ab6e7addc82516617a135f86b5ca;p=src%2Fapp-framework-main.git diff --git a/src/afm-launch.c b/src/afm-launch.c index 87c5b12..8391943 100644 --- a/src/afm-launch.c +++ b/src/afm-launch.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright 2015, 2016 IoT.bzh author: José Bollo @@ -109,6 +109,7 @@ static const char readystr[] = "READY=1"; */ static const int ready_timeout = 1500; +#if defined(DUMP_LAUNCHERS) /* * dump all the known launchers to the 'file' */ @@ -132,6 +133,7 @@ static void dump_launchers(FILE *file) fprintf(file, "\n"); } } +#endif /* * update 'cread' to point the the next token @@ -487,6 +489,7 @@ static int mkport() /* %% % %a appid desc->appid +%b bindings desc->bindings %c content desc->content %D datadir params->datadir %H height desc->height @@ -494,7 +497,6 @@ static int mkport() %I icondir FWK_ICON_DIR %m mime-type desc->type %n name desc->name -%p plugins desc->plugins %P port params->port %r rootdir desc->path %R readyfd params->readyfd @@ -571,6 +573,9 @@ static union arguments instantiate_arguments( c = *p++; switch (c) { case 'a': v = desc->appid; break; + case 'b': + v = "" /*TODO:desc->bindings*/; + break; case 'c': v = desc->content; break; case 'D': v = params->datadir; break; case 'H': @@ -589,9 +594,6 @@ static union arguments instantiate_arguments( params->port); v = port; break; - case 'p': - v = "" /*TODO:desc->plugins*/; - break; case 'R': if(!data) sprintf(readyfd, "%d", @@ -669,7 +671,7 @@ static pid_t launch( ) { int rc; - char **args; + char **args, **env; pid_t pid; int rpipe[2]; struct pollfd pfd; @@ -684,9 +686,13 @@ static pid_t launch( /* instanciate the arguments */ params->readyfd = rpipe[1]; args = instantiate_arguments(exec->args, desc, params, 1).vector; - if (args == NULL) { + env = instantiate_arguments((const char * const*)environ, + desc, params, 1).vector; + if (args == NULL || env == NULL) { close(rpipe[0]); close(rpipe[1]); + free(args); + free(env); ERROR("out of memory in master"); errno = ENOMEM; return -1; @@ -701,6 +707,7 @@ static pid_t launch( close(rpipe[0]); close(rpipe[1]); free(args); + free(env); ERROR("master fork failed: %m"); return -1; } @@ -710,6 +717,7 @@ static pid_t launch( close(rpipe[1]); free(args); + free(env); pfd.fd = rpipe[0]; pfd.events = POLLIN; @@ -759,7 +767,7 @@ static pid_t launch( } /* executes the process */ - rc = execve(args[0], args, environ); + rc = execve(args[0], args, env); ERROR("failed to exec master %s: %m", args[0]); _exit(1); return -1; @@ -848,7 +856,7 @@ static struct desc_launcher *search_launcher(const char *type, for (dl = launchers ; dl ; dl = dl->next) if (dl->mode == mode) for (tl = dl->types ; tl != NULL ; tl = tl->next) - if (!strcmp(tl->type, type)) + if (!strcasecmp(tl->type, type)) return dl; return NULL; } @@ -934,8 +942,13 @@ int afm_launch_initialize() else groupid = (gid_t)-1; + /* reads the configuration file */ rc = read_configuration_file(FWK_LAUNCH_CONF); - /* dump_launchers(stderr); */ +#if defined(DUMP_LAUNCHERS) + if (!rc) + dump_launchers(stderr); +#endif + return rc; }