__coreclrLib(nullptr),
__hostHandle(nullptr),
__domainId(-1),
- fd(0),
+ __fd(-1),
__initialized(false),
__isProfileMode(false)
{
dispose();
}
-int CoreRuntime::initialize(bool standalone, bool useDlog)
+int CoreRuntime::initialize(bool standalone, bool useDlog, const char* corerunRoot)
{
// checkInjection checks dotnet-launcher run mode
// At the moment, this mechanism is used only when the Memory Profiler is started.
// To avoid gdbus blocking issue, below function should be called after fork()
initEnvForSpecialFolder();
- fd = open("/proc/self", O_DIRECTORY);
- std::string appRoot = std::string("/proc/self/fd/") + std::to_string(fd);
- std::string appBin = concatPath(appRoot, "bin");
- std::string appLib = concatPath(appRoot, "lib");
- std::string appTac = concatPath(appBin, TAC_SYMLINK_SUB_DIR);
- std::string probePath = appBin + ":" + appLib + ":" + appTac;
- std::string NIprobePath = concatPath(appBin, APP_NI_SUB_DIR) + ":" + concatPath(appLib, APP_NI_SUB_DIR) + ":" + appTac;
std::string tpa = getTPA();
std::string runtimeDir = getRuntimeDir();
- std::string nativeLibPath = getExtraNativeLibDirs(appRoot) + ":" + appBin + ":" + appLib + ":" + __nativeLibDirectory + ":" + runtimeDir;
std::string appName = std::string("dotnet-launcher-") + std::to_string(getpid());
+ std::string probePath;
+ std::string NIprobePath;
+ std::string nativeLibPath;
+
+ if (corerunRoot) {
+ probePath = corerunRoot;
+ NIprobePath = corerunRoot;
+ nativeLibPath = corerunRoot;
+ } else {
+ __fd = open("/proc/self", O_DIRECTORY);
+ if (__fd < 0) {
+ _ERR("Failed to open /proc/self");
+ return -1;
+ }
+ std::string appRoot = std::string("/proc/self/fd/") + std::to_string(__fd);
+ std::string appBin = concatPath(appRoot, "bin");
+ std::string appLib = concatPath(appRoot, "lib");
+ std::string appTac = concatPath(appBin, TAC_SYMLINK_SUB_DIR);
+ probePath = appRoot + ":" + appBin + ":" + appLib + ":" + appTac;
+ NIprobePath = concatPath(appBin, APP_NI_SUB_DIR) + ":" + concatPath(appLib, APP_NI_SUB_DIR) + ":" + appTac;
+ nativeLibPath = getExtraNativeLibDirs(appRoot) + ":" + appBin + ":" + appLib + ":" + __nativeLibDirectory + ":" + runtimeDir;
+ }
if (!initializeCoreClr(appName.c_str(), probePath.c_str(), NIprobePath.c_str(), nativeLibPath.c_str(), tpa.c_str())) {
_ERR("Failed to initialize coreclr");
pluginSetAppInfo(appId, path);
- int fd2 = open(root, O_DIRECTORY);
- dup3(fd2, fd, O_CLOEXEC);
- if (fd2 >= 0)
- close(fd2);
+ // override root path for application launch mode (candidate / standalone mode)
+ if (__fd >= 0) {
+ int fd2 = open(root, O_DIRECTORY);
+ dup3(fd2, __fd, O_CLOEXEC);
+ if (fd2 >= 0)
+ close(fd2);
+ }
// set application data path to coreclr environment.
// application data path can be changed by owner. So, we have to set data path just before launching.
snprintf(appId, 16, "%s", "dotnet-launcher");
appRoot = baseName(argv[1]);
- if (runtime->initialize(true, false) != 0) {
+ if (runtime->initialize(true, false, appRoot.c_str()) != 0) {
_ERR("Failed to initialize");
return 1;
}
}
_INFO("AUL_APPID : %s", appId);
- if (runtime->initialize(true, true) != 0) {
+ if (runtime->initialize(true, true, NULL) != 0) {
_ERR("Failed to initialize");
return 1;
}
}
Launchpad.onCreate = [&runtime]() {
- if (runtime->initialize(false, true) != 0) {
+ if (runtime->initialize(false, true, NULL) != 0) {
_ERR("Failed to initialized");
} else {
_INFO("Success to initialized");