Skip to content

Provide a method to send PosixSignal to the Process. #99506

@moh-hassan

Description

@moh-hassan

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions