From: Mathieu Desnoyers Date: Tue, 29 Nov 2011 00:20:09 +0000 (-0500) Subject: Setup LD_LIBRARY_PATH if 32/64 bit consumer libdir is set X-Git-Tag: v2.0-pre15~69^2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8f4905da7879943cd744ff55074ff0bc0e4f61cf;p=lttng-tools.git Setup LD_LIBRARY_PATH if 32/64 bit consumer libdir is set Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index 7e58ff781..89a42528c 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -1532,18 +1532,88 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) break; case LTTNG_CONSUMER64_UST: { - execl(consumerd64_path, verbosity, "-u", + char *tmpnew; + + if (consumerd64_libdir[0] != '\0') { + char *tmp; + size_t tmplen; + + tmp = getenv("LD_LIBRARY_PATH"); + if (!tmp) { + tmp = ""; + } + tmplen = strlen("LD_LIBRARY_PATH=") + + strlen(consumerd64_libdir) + 1 /* : */ + strlen(tmp); + tmpnew = zmalloc(tmplen + 1 /* \0 */); + if (!tmpnew) { + ret = -ENOMEM; + goto error; + } + strcpy(tmpnew, "LD_LIBRARY_PATH="); + strcat(tmpnew, consumerd64_libdir); + if (tmp[0] != '\0') { + strcat(tmpnew, ":"); + strcat(tmpnew, tmp); + } + ret = putenv(tmpnew); + if (ret) { + ret = -errno; + goto error; + } + } + ret = execl(consumerd64_path, verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, NULL); + if (consumerd64_libdir[0] != '\0') { + free(tmpnew); + } + if (ret) { + goto error; + } break; } case LTTNG_CONSUMER32_UST: { - execl(consumerd32_path, verbosity, "-u", + char *tmpnew; + + if (consumerd32_libdir[0] != '\0') { + char *tmp; + size_t tmplen; + + tmp = getenv("LD_LIBRARY_PATH"); + if (!tmp) { + tmp = ""; + } + tmplen = strlen("LD_LIBRARY_PATH=") + + strlen(consumerd32_libdir) + 1 /* : */ + strlen(tmp); + tmpnew = zmalloc(tmplen + 1 /* \0 */); + if (!tmpnew) { + ret = -ENOMEM; + goto error; + } + strcpy(tmpnew, "LD_LIBRARY_PATH="); + strcat(tmpnew, consumerd32_libdir); + if (tmp[0] != '\0') { + strcat(tmpnew, ":"); + strcat(tmpnew, tmp); + } + ret = putenv(tmpnew); + if (ret) { + ret = -errno; + goto error; + } + } + ret = execl(consumerd32_path, verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, NULL); + if (consumerd32_libdir[0] != '\0') { + free(tmpnew); + } + if (ret) { + goto error; + } break; } default: @@ -1560,6 +1630,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) perror("start consumer fork"); ret = -errno; } +error: return ret; }