#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

#66 in #detect

Download history 8422/week @ 2024-07-20 7373/week @ 2024-07-27 8494/week @ 2024-08-03 7594/week @ 2024-08-10 9007/week @ 2024-08-17 8287/week @ 2024-08-24 7294/week @ 2024-08-31 7309/week @ 2024-09-07 6963/week @ 2024-09-14 7257/week @ 2024-09-21 8009/week @ 2024-09-28 7074/week @ 2024-10-05 7423/week @ 2024-10-12 7372/week @ 2024-10-19 7564/week @ 2024-10-26 8397/week @ 2024-11-02

32,181 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