-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed as not planned
Description
There is a new feature in net6 and above that enable handling of PosixSignal
like:
using (var intHandler = PosixSignalRegistration.Create(PosixSignal.SIGINT, HandleSignal))
{
Console.WriteLine("Press Ctrl+C to trigger handler.");
LongRunning();
}
void HandleSignal(PosixSignalContext posixSignalContext)
{
Console.WriteLine($"Received signal: {posixSignalContext.Signal}");
}
There is example in stackoverflow (https://stackoverflow.com/a/35809358) that use mono package to send SIGINT but it is not compatible with net6 PosixSignal.
It is nice if dotnet provide API to send SIGINt/SIGTERM/..signal to the process to enable graceful stopping/shutdown process.
something like:
SendSignal(int processId, PosixSignal signal)
``
The method can be part of Process class.