-
Couldn't load subscription status.
- Fork 5.2k
Description
I have a Linux C++ program works like:
Process start
Module1 run
Module2 run
...
Receive SIGTERM
Module1 exit
Module2 exit
...
Save data
Process exit
Recently, I needed to integrate a third-party C# module. Following the hosting example, I was able to run the C# DLL module.
However, when sending SIGTERM to shut down the process, coreclr.so exits the process directly:
Process start
Module1 run
Module2 run
Module_CSharp run
...
Receive SIGTERM
CoreCLR exits the whole process
// The following never runs
Module1 exit
Module2 exit
...
Save data
Process exit
After several days of research, I couldn't find an API to ignore POSIX signals in C#. The closest solution I found is:
PosixSignalRegistration.Create(PosixSignal.SIGTERM, (ctx) =>
{
ctx.Cancel = true;
});This only prevents coreclr from shutting down, but coreclr still consumes the signal. What I'm looking for is an API to prevent coreclr from receiving POSIX signals and leave the signal handling to the main thread:
Process start
Module1 run
Module2 run
Module_C# run
Make CoreCLR ignore POSIX signals <<< looking for something like signal(SIGTERM, SIG_IGN)
...
Receive SIGTERM
Module1 exit
Module2 exit
Module_CSharp exit and shut down CoreCLR <<< looking for api to shutdown CoreCLR but not exit the process
...
Save data
Process exit
Currently, I use PosixSignalRegistration to call a C++ function to tell the main thread to save data and exit, but I cannot shut down coreclr when process exit.
What am I missing?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status