Skip to content

Consider API to handle windows logoff #41183

Open

Description

@sbomer

With #41101, we handle the shutdown event. It would be good also to handle the logoff event. From https://docs.microsoft.com/en-us/windows/console/handlerroutine

When a console application is run as a service, it receives a modified default console control handler. This modified handler does not call ExitProcess when processing the CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals. This allows the service to continue running after the user logs off.

Since CTRL_LOGOFF_EVENT doesn't necessarily terminate a process, we should consider providing a cancelable API for logoff instead of ProcessExit.

Related is this discussion of a cancelable API for SIGTERM: #35990 (comment)

Activity

  1. Dotnet-GitSync-Bot commented on Aug 21, 2020

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

  2. danmoseley commented on Aug 21, 2020

    @danmoseley
    Contributor

    Next step: someone draft an API proposal in this format

  3. added
    api-needs-workAPI needs work before it is approved, it is NOT ready for implementation
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 24, 2020
  4. added this to the Future milestone on Aug 24, 2020
  5. removed
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on Jun 25, 2021
  6. MojtabaTajik commented on Apr 8, 2024

    @MojtabaTajik
    Contributor

    @danmoseley I think we can close this one based on this fix, yes?

  7. jkotas commented on Apr 10, 2024

    @jkotas
    Member

    I think we can close this one based on #35990 (comment), yes?

    The PosixSignalRegistration API does not handle CTRL_LOGOFF_EVENT that this issue is about.

  8. dotnet-policy-service commented on Jul 23, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-console
    See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions