Skip to content

Grace handling user requested process termination #4799

Open
@JanKrivanek

Description

@JanKrivanek

Background:

When user requests a processing exit (via Ctrl-C or Ctrl-Break), templating engine does not grace shut any of it's async processing and the process terminates with wxit code 0xC000013A (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 sdk
Ideally 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 with Environment.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Work that is nice to havearea: CLIRelated 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.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions