#wsl #windows #run-time #detection

wsl

Detect if the program is running under Windows Subsystem for Linux

1 unstable release

0.1.0 Jun 12, 2019

#152 in Operating systems

Download history 1936/week @ 2022-02-28 1930/week @ 2022-03-07 2170/week @ 2022-03-14 1820/week @ 2022-03-21 1771/week @ 2022-03-28 2110/week @ 2022-04-04 2087/week @ 2022-04-11 2520/week @ 2022-04-18 4146/week @ 2022-04-25 2808/week @ 2022-05-02 3706/week @ 2022-05-09 5421/week @ 2022-05-16 9633/week @ 2022-05-23 5822/week @ 2022-05-30 6165/week @ 2022-06-06 6157/week @ 2022-06-13

28,198 downloads per month
Used in 5 crates (4 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