-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.Processhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
Background and motivation
dotnet-watch needs to be able to terminate process gracefully, i.e. give it a chance to clean up resources.
On Windows this API would call GenerateConsoleCtrlEvent, on Unix it would send SIGTERM signal.
Currently this requires reimplementing both process creation and termination using P/Invokes.
API Proposal
Multiple options. One option is to add parameter to Process.Kill that indicates whether we want forced kill or "soft" termination (Ctrl+C/SIGTERM).
Process.Kill(bool entireProcessTree, bool forced = true);ProcessStartInfo might need a bool property, say EnableConsoleControlEvents that allows Kill to send Ctrl+C.
API Usage
var process = new Process
{
StartInfo =
{
EnableConsoleControlEvents = true
// file name, arguments, output redirection, etc.
}
};
process.Start();
process.Kill(entireProcessTree: false, forced: false);
process.WaitForExit();Alternative Designs
Related: #71515
Risks
No response
danmoseley, D3-LucaPiombino, davidfowl, Mrxx99, 0xfeeddeadbeef and 1 more
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.Processhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors