Register default signal handler
authorWoongsuk Cho <ws77.cho@samsung.com>
Tue, 12 Mar 2024 01:47:36 +0000 (10:47 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Tue, 12 Mar 2024 04:31:43 +0000 (13:31 +0900)
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

index 39c3695..8431610 100644 (file)
@@ -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) {