Rework dotnet executable (#204)
[platform/core/dotnet/launcher.git] / NativeLauncher / launcher / lib / dotnet_launcher.cc
index 5dc2304..7ed7f39 100644 (file)
@@ -347,7 +347,7 @@ CoreRuntime::~CoreRuntime()
        dispose();
 }
 
-int CoreRuntime::initialize(LaunchMode launchMode, bool useDlog, const char* rootPath)
+int CoreRuntime::initialize(LaunchMode launchMode)
 {
        // checkInjection checks dotnet-launcher run mode
        // At the moment, this mechanism is used only when the Memory Profiler is started.
@@ -399,7 +399,7 @@ int CoreRuntime::initialize(LaunchMode launchMode, bool useDlog, const char* roo
                return -1;
        }
 
-       if (useDlog && !pluginHasLogControl()) {
+       if (!pluginHasLogControl()) {
                if (initializeLogManager() < 0) {
                        _ERR("Failed to initnialize LogManager");
                        return -1;
@@ -449,31 +449,22 @@ int CoreRuntime::initialize(LaunchMode launchMode, bool useDlog, const char* roo
        // To avoid gdbus blocking issue, below function should be called after fork()
        initEnvForSpecialFolder();
 
+       __fd = open("/proc/self", O_DIRECTORY);
+       if (__fd < 0) {
+               _ERR("Failed to open /proc/self");
+               return -1;
+       }
+
        std::string tpa = getTPA();
        std::string runtimeDir = getRuntimeDir();
        std::string appName = std::string("dotnet-launcher-") + std::to_string(getpid());
-       std::string probePath;
-       std::string NIprobePath;
-       std::string nativeLibPath;
-
-       if (launchMode == LaunchMode::corerun) {
-               probePath = rootPath;
-               NIprobePath = rootPath;
-               nativeLibPath = rootPath;
-       } 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;
-       }
+       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 = appRoot + ":" + appBin + ":" + appLib + ":" + appTac;
+       std::string NIprobePath = concatPath(appBin, APP_NI_SUB_DIR) + ":" + concatPath(appLib, APP_NI_SUB_DIR) + ":" + appTac;
+       std::string 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");