From 15f113ebfb2c3a61f1de01b22a2a74d707bdd26b Mon Sep 17 00:00:00 2001 From: Woongsuk Cho Date: Tue, 12 Mar 2024 10:47:36 +0900 Subject: [PATCH] Register default signal handler When the .NET Runtime receives SIGABRT and the previous handler is the default handler, the .NET Runtime restores the default handler as the current handler and continues. As a result, if a signal handler has not been registered before the .NET Runtime, the application will be terminated only after calling SIGAGRT twice. To avoid this situation, add signal handler before coreclr_initialize() --- NativeLauncher/launcher/lib/core_runtime.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/NativeLauncher/launcher/lib/core_runtime.cc b/NativeLauncher/launcher/lib/core_runtime.cc index 39c3695..8431610 100644 --- a/NativeLauncher/launcher/lib/core_runtime.cc +++ b/NativeLauncher/launcher/lib/core_runtime.cc @@ -307,6 +307,13 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) __isProfileMode = true; } + // When the .NET Runtime receives SIGABRT and the previous handler is the default handler, + // the .NET Runtime restores the default handler as the current handler and continues. + // As a result, if a signal handler has not been registered before the .NET Runtime, + // the application will be terminated only after calling SIGAGRT twice. + // To avoid this situation, add signal handler before coreclr_initialize() + registerSigHandler(); + // plugin initialize should be called before creating threads. // In case of VD plugins, attaching secure zone is done in the plugin_initialize(). // When attaching to a secure zone, if there is a created thread, it will failed. @@ -420,10 +427,9 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) return -1; } - // VD has their own signal handler. - if (!pluginHasLogControl()) { - registerSigHandler(); - } + // This code is no longer needed because log redirection is performed by the system. + // However, since additional work can be done in the VD plugin, the function call is kept. + pluginHasLogControl(); int st = createDelegate(__hostHandle, __domainId, "Tizen.Runtime", "Tizen.Runtime.Environment", "SetEnvironmentVariable", (void**)&setEnvironmentVariable); if (st < 0 || setEnvironmentVariable == nullptr) { -- 2.34.1