* limitations under the License.
*/
-#include "injection.h"
#include "dotnet/dotnet_launcher.h"
#include "utils.h"
#include "log.h"
#include <sys/types.h>
#include <unistd.h>
-#define CMD_LINE_SIZE 24 // sizeof("/usr/bin/dotnet-launcher")
+// 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
static std::string StandaloneOption("--standalone");
+static std::string PaddingOption("--PADDING_TO_CHANGE_CMDLINE");
extern "C" int realMain(int argc, char *argv[], const char* mode)
{
bool standaloneMode = false;
char* standalonePath = nullptr;
bool corerunMode = false;
+ bool paddingExist = false;
std::vector<char*> vargs;
if (StandaloneOption.compare(argv[i]) == 0) {
standaloneMode = true;
- if (i > argc-1) {
+ if (i > argc - 1) {
fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
return 1;
}
i++;
standalonePath = argv[i];
+ } else if (PaddingOption.compare(argv[i]) == 0) {
+ paddingExist = true;
} else {
vargs.push_back(argv[i]);
}
std::unique_ptr<CoreRuntime> runtime(new CoreRuntime(mode));
+ // Intiailize ecore first (signal handlers, etc.) before runtime init.
+ ecore_init();
+
if (corerunMode) {
- _INFO("##### Run it corerun Mode #########");
- char appId[1024] = {0,};
+ _INFO("##### Run in corerun mode #####");
+ char appId[APPID_MAX_LENGTH] = {0,};
std::string appRoot;
snprintf(appId, 16, "%s", "dotnet-launcher");
appRoot = baseName(argv[1]);
return 1;
}
} else if (standaloneMode) {
- _INFO("##### Run it standalone Mode #########");
- char appId[1024] = {0,};
+ _INFO("##### Run in standalone mode #####");
+ char appId[APPID_MAX_LENGTH] = {0,};
std::string appRoot;
if (AUL_R_OK == aul_app_get_appid_bypid(getpid(), appId, sizeof(appId))) {
const char* appRootPath = aul_get_app_root_path();
}
// change cmdline from dotnet-launcher to executable path
- memset(argv[0], '\0', CMD_LINE_SIZE);
- snprintf(argv[0], CMD_LINE_SIZE - 1, "%s", appId);
+ int cmdlineSize = paddingExist ? APPID_MAX_LENGTH : APPID_MAX_LENGTH - PaddingOption.length();
+ memset(argv[0], '\0', cmdlineSize);
+ snprintf(argv[0], cmdlineSize, "%s", appId);
int argsLen = vargs.size();
char** args = &vargs[0];
return 1;
}
} else {
+ // change cmdline from dotnet-hydra-launcher to dotnet-launcher
+ if (strcmp(argv[0], "/usr/bin/dotnet-hydra-launcher") == 0) {
+ memset(argv[0], '\0', strlen("/usr/bin/dotnet-hydra-launcher"));
+ snprintf(argv[0], strlen("/usr/bin/dotnet-launcher") + 1, "/usr/bin/dotnet-launcher");
+ }
+
Launchpad.onCreate = [&runtime]() {
if (runtime->initialize(false) != 0)
_ERR("Failed to initialized");
int main(int argc, char *argv[])
{
- /* checkInjection checks dotnet-launcher run mode,
- if it contains DOTNET_LAUNCHER_INJECT variable, it injects library.
- At the moment, this mechanism is used only when the Memory Profiler is started.
- */
- int res = checkInjection();
- if (res != 0) {
- return 1;
- }
-
return realMain(argc, argv, "default");
}