Skip to content

WSL detection is set based on build system, which is often Real Linux™ #5619

@smanning

Description

@smanning

Found #5298 after spending quite some time tracking down why fish (3.0.0) was giving me "Could not send own process..." pipe errors on my Windows 10 WSL install (1803). However, the issue states that a message was added to instruct people to upgrade to "Windows 10 1809/17763 or higher". I never got this message. Looking at the code on the master I see this:

            if (is_windows_subsystem_for_linux() && errno == EPERM) {
                debug_safe(1, "Please update to Windows 10 1809/17763 or higher to address known issues "
                        "with process groups and zombie processes.");
            }

The definition of is_windows_subsystem_for_linux() shows this:

/// Detect if we are Windows Subsystem for Linux by inspecting /proc/sys/kernel/osrelease
/// and checking if "Microsoft" is in the first line.
/// See https://github.com/Microsoft/WSL/issues/423 and Microsoft/WSL#2997
constexpr bool is_windows_subsystem_for_linux() {
    // This function is called after fork() and before exec() in postfork.cpp. Make sure we
    // don't allocate any memory here!
#ifdef WSL
    return true;
#else
    return false;
#endif
}

The comment states that it is going to inspect /proc/sys/kernel/osrelease to determine if fish is running on WSL. But when I scan all of the files in the project I find nothing that does this inspection and the only way the "WSL" is set is if fish was built using cmake on a WSL machine. I tested this and it does print the error if you build it that way, but that's an unlikely scenario for most users of WSL.

fish, version 3.0.0-309-gc7656e66
Linux MYHOSTNAME 4.4.0-17134-Microsoft #523-Microsoft Mon Dec 31 17:49:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
xterm-256color (WSL default terminal)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions