Skip to content

wslc system session terminate claims to accept a session name, but only supports terminating the default sessionΒ #41222

Closed

Description

@idann

Windows Version

Microsoft Windows [Version 10.0.26200.8973]

WSL Version

2.9.4.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.18.35.2-1

Distro Version

No response

Other Software

No response

Repro Steps

  1. Create a defaultly-named session by running a container with WSLC under your own account. E.g.:
    C:\Windows\System32>wslc run --rm hello-world
    Hello from Docker!
    [...]
  2. Create a second defaultly-named session by running a container under your own account, but elevated
  3. Run wslc system session list (and see in Task Manager). You now have two session VMs: wslc-cli-User and wslc-cli-admin-User.
    Due to being lightweight Hyper-V VMs, your only way of terminating them is with wslc system session terminate.
  4. Run wslc system session terminate --help
  5. Notice the command help specifies it can accept a session name in the description, but the command format does not mention it:
    Copyright (c) Microsoft Corporation. All rights reserved.
    For privacy information about this product please visit https://aka.ms/privacy.
    
    Terminates an active session. If no session is specified, the default session will be terminated.
    
    Usage: wslc system session terminate [<options>]
    
    The following options are available:
      -?,--help  Shows help about the selected command
  6. Attempt to specify a session name (or ID) anyway. Notice it complains about a positional argument that was not expected:
    C:\Windows\System32>wslc system session list
    ID   Creator PID   Display Name
    1    1234          wslc-cli-User
    2    5678          wslc-cli-admin-User
    C:\Windows\System32>wslc system session terminate 2
    Copyright (c) Microsoft Corporation. All rights reserved.
    For privacy information about this product please visit https://aka.ms/privacy.
    
    Found a positional argument when none was expected: '2'
    [...help text follows...]
    C:\Windows\System32>wslc system session terminate wslc-cli-User
    Copyright (c) Microsoft Corporation. All rights reserved.
    For privacy information about this product please visit https://aka.ms/privacy.
    
    Found a positional argument when none was expected: 'wslc-cli-User'
    [...help text follows...]
  7. Running an unspecified terminate command works, but of course only terminates the session owned by the current user and integrity level:
    C:\Windows\System32>wslc system session terminate
    
    C:\Windows\System32>wslc system session list
    ID   Creator PID   Display Name
    1    1234          wslc-cli-User
  8. Running [...]terminate a second time fails as the session does not exist anymore:
    C:\Windows\System32>wslc system session terminate
    Session not found: 'wslc-cli-admin-User'
    Error code: WSLC_E_SESSION_NOT_FOUND

The end result is: If you started several sessions across user accounts and integrity levels, those sessions can only be terminated by the users (and integrity levels) who started them.

Expected Behavior

wslc system session terminate should accept a session name (or ID if the ordering of wslc system session list is consistent across calls and can be trusted), and allow a user at or above trust level to terminate another session. I.e.: a non-elevated user account would be able to terminate their own non-elevated session, while an elevated user account would be able to terminate all other users' elevated and non-elevated sessions.

If not, the command description should be amended.

However, in that case, due to Hyper-V lightweight VMs being unmanageable with regular tools, a user can end up with essentially "leaked" VMs if they don't know about the sessions' user + integrity distinction.

Actual Behavior

wslc system session terminate does not accept any other option than --help/-?, and can only terminate the default session.

See repro steps for full console output of this & related commands.

Diagnostic Logs

No response

Activity

  1. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. changed the title [-]"wslc system session terminate" claims to accept a session name, but only supports terminating the default session[/-] [+]`wslc system session terminate` claims to accept a session name, but only supports terminating the default session[/+] on Aug 1, 2026
  3. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  4. idann commented on Aug 1, 2026

    @idann
    Author

    /feature
    This is effectively a feature request as it details a feature that seems to be described but not implemented.

  5. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor
    Diagnostic information
    Found '/feature', adding tag 'feature'
    
  6. dkbennett commented on Sep 11, 2026

    @dkbennett
    Member

    The session specifier is a global argument, which is placed after the root: wslc --session foo system session terminate

    This functionality works and is tested, but the global specifier can be a little confusing. I have a PR which improves this such that adding --session anywhere in the command line will generate a prescriptive error on where to place it instead of an unknown/invalid argument error.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions