You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ignore posix signal and shutdown nethost gracefully #106262
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:
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.
Activity
dotnet-policy-service commentedon Aug 12, 2024
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Aug 12, 2024
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
jkotas commentedon May 16, 2025
Fixed by #115494. libcoreclr.so does not consume the SIGTERM signal anymore.