error = storage_get_directory(__storageId, type, &path);
if (error == STORAGE_ERROR_NONE && path != NULL) {
- setenv(key, const_cast<char *>(path), 1);
+ if (setEnvironmentVariable) {
+ setEnvironmentVariable(key, const_cast<char *>(path));
+ } else {
+ _ERR("coreclr is not initialized!. setEnvironmentVariable() function is not ready!");
+ _exit(0);
+ }
free(path);
}
}
_INFO("libcoreclr dlopen and dlsym success");
- // Set environment for System.Environment.SpecialFolder
- // Below function creates dbus connection by callging storage API.
- // If dbus connection is created bofere fork(), forked process cannot use dbus.
- // To avoid gdbus blocking issue, below function should be called after fork()
- initEnvForSpecialFolder();
-
std::string tpa;
char* pluginTPA = pluginGetTPA();
if (pluginTPA && pluginTPA[0] != '\0') {
removeDebugPipe();
}
+
+ // Set environment for System.Environment.SpecialFolder
+ // Below function creates dbus connection by callging storage API.
+ // If dbus connection is created bofere fork(), forked process cannot use dbus.
+ // To avoid gdbus blocking issue, below function should be called after fork()
+ // Addtionally, setenv() is not thread-safe function. storage API makes thread internally
+ // and it makes crash while calling setenv(). So, use setEnvrionmentVariable() instead of setenv()
+ initEnvForSpecialFolder();
+
__initialized = true;
_INFO("CoreRuntime initialize success");