#detection #run-time #detect #windows

wsl

Detect if the program is running under Windows Subsystem for Linux

1 unstable release

0.1.0 Jun 12, 2019

#559 in Operating systems

Download history 10440/week @ 2024-03-25 11597/week @ 2024-04-01 10140/week @ 2024-04-08 10895/week @ 2024-04-15 10557/week @ 2024-04-22 9131/week @ 2024-04-29 11686/week @ 2024-05-06 10481/week @ 2024-05-13 8516/week @ 2024-05-20 10384/week @ 2024-05-27 11495/week @ 2024-06-03 10971/week @ 2024-06-10 10064/week @ 2024-06-17 9285/week @ 2024-06-24 10146/week @ 2024-07-01 8751/week @ 2024-07-08

38,729 downloads per month
Used in 9 crates (7 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