Grace handling user requested process termination #4799
Labels
area: CLI
Related to dotnet new CLI (usually dotnet/TemplateEngine.CLI source code)
Priority:3
Work that is nice to have
triaged
The issue was evaluated by the triage team, placed on correct area, next action defined.
Milestone
Background:
When user requests a processing exit (via
Ctrl-C
orCtrl-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
CancelOnProcessTermination
to 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
CancelOnProcessTermination
in 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 anywaysThe text was updated successfully, but these errors were encountered: