From 6f7e3e4b3e048ca32be03206a22bb29293e7b52f Mon Sep 17 00:00:00 2001 From: Hyungju Lee Date: Tue, 3 Mar 2020 11:37:57 +0900 Subject: [PATCH] Full executable path to support crash-worker in case of standalone Change-Id: I519bf8a430c5fd92bb5d43a7fe9092c3514ffa36 --- NativeLauncher/dotnet.launcher | 2 +- NativeLauncher/launcher/main.cc | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/NativeLauncher/dotnet.launcher b/NativeLauncher/dotnet.launcher index b583e1e..0cd09a2 100644 --- a/NativeLauncher/dotnet.launcher +++ b/NativeLauncher/dotnet.launcher @@ -2,6 +2,6 @@ NAME dotnet-launcher EXE /usr/bin/dotnet-launcher APP_TYPE dotnet -EXTRA_ARG --PADDING_TO_CHANGE_CMDLINE +EXTRA_ARG --PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE EXTRA_ARG --standalone diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 093e9af..f09705b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -28,12 +28,13 @@ #include #include -// By the specification, application id must be shorter than 50 character. -// To add margin, set CMD_LINE_SIZE to 64. (padding size is included) -#define APPID_MAX_LENGTH 52 +// By the specification, application id must be shorter than 50 characters. +// Current length of argv[0] is 25 with a space. ("/usr/bin/dotnet-launcher ") +// To be able to change argv[0] when standalone mode padding for executable path is added. +#define APPID_MAX_LENGTH (25 + 105) static std::string StandaloneOption("--standalone"); -static std::string PaddingOption("--PADDING_TO_CHANGE_CMDLINE"); +static std::string PaddingOption("--PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE_PADDING_TO_CHANGE_CMDLINE"); extern "C" int realMain(int argc, char *argv[], const char* mode) { @@ -118,7 +119,7 @@ extern "C" int realMain(int argc, char *argv[], const char* mode) // change cmdline from dotnet-launcher to executable path int cmdlineSize = paddingExist ? APPID_MAX_LENGTH : APPID_MAX_LENGTH - PaddingOption.length(); memset(argv[0], '\0', cmdlineSize); - snprintf(argv[0], cmdlineSize, "%s", appId); + snprintf(argv[0], cmdlineSize, "%s", standalonePath); int argsLen = vargs.size(); char** args = &vargs[0]; -- 2.7.4