microsoft / microsoft/WSL

wslapi WslGetDistributionState proposal

Open
#10,401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
There seems to be no programmatic way to get the current state of a specific distro, currently there are no API functions that could get this information, nor it is stored/updated on the registry.

The only way I have found to actually know if a Distro is running or stopped is to get use wsl.exe --list --verbose or wsl.exe --list --running and parse the output.

**Describe the solution you'd like**
It would be nice if there is a function where you can pass the distro identifier and it returns its current state.
```
HRESULT WslGetDistributionState(
[in] PCWSTR distributionName,
[out] WSL_DISTRIBUTION_STATE wslDistributionState
);

typedef enum {
WSL_DISTRIBUTION_STATE_STOPPED = 0x0,
WSL_DISTRIBUTION_STATE_RUNNING = 0x1,
WSL_DISTRIBUTION_STATE_STARTING = 0x2,
WSL_DISTRIBUTION_STATE_STOPPING = 0x3,
} WSL_DISTRIBUTION_STATE;
```

**Describe alternatives you've considered**
n/a.

**Additional context**
I haven't found any other possible programmatic way to know what possible states there are or even any documentation on how the wsl.exe itself define a Distro state. As there is no 1:1 tie to any running processes or PID that could be binded to.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests. Start by tracing how wsl.exe --list --verbose and --list --running determine a distribution's state, then review the existing WSL API patterns. Done means a supported API accepts a distribution identifier and reports its current state consistently.

Written by the indexing model from the issue text.

Assessment

Domain
api, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.