-
Notifications
You must be signed in to change notification settings - Fork 397
Grace handling user requested process termination #4799
Copy link
Copy link
Open
Labels
Priority:3Work that is nice to haveWork that is nice to havearea: CLIRelated to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code)Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code)triagedThe issue was evaluated by the triage team, placed on correct area, next action defined.The issue was evaluated by the triage team, placed on correct area, next action defined.
Milestone
Metadata
Metadata
Assignees
Labels
Priority:3Work that is nice to haveWork that is nice to havearea: CLIRelated to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code)Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code)triagedThe issue was evaluated by the triage team, placed on correct area, next action defined.The issue was evaluated by the triage team, placed on correct area, next action defined.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Background:
When user requests a processing exit (via
Ctrl-CorCtrl-Break), templating engine does not grace shut any of it's async processing and the process terminates with wxit code0xC000013A(STATUS_CONTROL_C_EXIT)Improved expected behavior:
When user requests a processing exit, templating engine safely cancels all of it's processing, exits once done and signals the situation with exit code
130(https://tldp.org/LDP/abs/html/exitcodes.html)How to achieve this:
We should resort from trying to intercept the singla ourselves (with
SetConsoleCtrlHandler)Rather we should use the build in functionality of process termination handling within command-line-api
This will require adding
CancelOnProcessTerminationto command line builder within sdkIdeally we should inject this handling for templating subcommand only - in case other subcommands cancellation logic would not be ready (hence leading to uncancellable process). Alternative might be to improve the
CancelOnProcessTerminationin command line api to allow optional termination processing timeout, after which expiry the process would exit anyway (probably withEnvironment.Exit(130)) - then we possibly could register the middleware for all dotnet subcommands - those not ready to grace handle cancellation on termination would keep terminating anyways