#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

#206 in Operating systems

Download history 9606/week @ 2023-08-10 10876/week @ 2023-08-17 9909/week @ 2023-08-24 8372/week @ 2023-08-31 9970/week @ 2023-09-07 9354/week @ 2023-09-14 9092/week @ 2023-09-21 9642/week @ 2023-09-28 10138/week @ 2023-10-05 9662/week @ 2023-10-12 12709/week @ 2023-10-19 12275/week @ 2023-10-26 11406/week @ 2023-11-02 12583/week @ 2023-11-09 15198/week @ 2023-11-16 10434/week @ 2023-11-23

51,809 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