#include <storage.h>
#include <app_common.h>
+#include "injection.h"
#include "utils.h"
#include "log.h"
#include "launcher.h"
struct sigaction sig_abrt_old;
static bool checkOnSigabrt = false;
+static bool checkOnTerminate = false;
static void onSigabrt(int signum)
{
// use unused variable to avoid build warning
ssize_t ret = write(STDERR_FILENO, "onSigabrt called\n", 17);
+ if (checkOnTerminate) {
+ ret = write(STDERR_FILENO, "onSigabrt called while terminate. go to exit\n", 45);
+ _unused(ret);
+ exit(0);
+ }
+
if (checkOnSigabrt) {
ret = write(STDERR_FILENO, "onSigabrt called again. go to exit\n", 35);
_unused(ret);
int CoreRuntime::initialize(bool standalone)
{
+ // 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) {
+ _ERR("Failed to initnialize Memory Profiler");
+ return -1;
+ }
#define __XSTR(x) #x
#define __STR(x) __XSTR(x)
if (!standalone)
putenv(const_cast<char *>("COMPlus_EnableDiagnostics=0"));
+ // Write Debug.WriteLine to stderr
+ putenv(const_cast<char *>("COMPlus_DebugWriteToStdErr=1"));
+
// read string from external file and set them to environment value.
setEnvFromFile();
void CoreRuntime::dispose()
{
+ // call plugin finalize function to notify finalize to plugin
+ // dlclose shoud be done after coreclr shutdown to avoid breaking signal chain
+ pluginFinalize();
+
+ // ignore the signal generated by an exception that occurred during shutdown
+ checkOnTerminate = true;
+
if (__hostHandle != nullptr) {
int st = shutdown(__hostHandle, __domainId);
if (st < 0)
if (!setEnvironmentVariable(u"XDG_DATA_HOME", envval)) {
_ERR("Failed to set XDG_DATA_HOME");
+
}
+
+ free(localDataPath);
}
pluginBeforeExecute();