#detection #running #linux #subsystem #windows-linux #detect #run-time

wsl

Detect if the program is running under Windows Subsystem for Linux

1 unstable release

0.1.0 Jun 12, 2019

#326 in Operating systems

Download history 11372/week @ 2023-11-21 13193/week @ 2023-11-28 13304/week @ 2023-12-05 12356/week @ 2023-12-12 9773/week @ 2023-12-19 5009/week @ 2023-12-26 6864/week @ 2024-01-02 10884/week @ 2024-01-09 12288/week @ 2024-01-16 9564/week @ 2024-01-23 11200/week @ 2024-01-30 9918/week @ 2024-02-06 13024/week @ 2024-02-13 12844/week @ 2024-02-20 10228/week @ 2024-02-27 9668/week @ 2024-03-05

47,792 downloads per month
Used in 10 crates (8 directly)

MIT license

3KB

Detect if the code is ran under Windows Subsystem for Linux

Usage

wsl::is_wsl() returns true under WSL, false otherwise.

Method

A semi-official source lists some pointers. We are going to use the simplest approach here: Testing if /proc/sys/kernel/osrelease contains string Microsoft or WSL.


lib.rs:

Detect if the program is running under Windows Subsystem for Linux

Usage

wsl::is_wsl()

No runtime deps