From 238f13a451f1d06c9aeaf4e8f09deee0865c5e24 Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 25 Jun 2026 21:58:50 +0000 Subject: [PATCH] Add WSL compatibility warning to Nping --- nping/nping.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nping/nping.cc b/nping/nping.cc index 1cf6e272d..836d8a8db 100644 --- a/nping/nping.cc +++ b/nping/nping.cc @@ -79,6 +79,11 @@ #include #include +#ifdef LINUX +/* Check for Windows Subsystem for Linux (WSL) */ +#include +#endif + NpingOps o; EchoClient ec; EchoServer es; @@ -199,6 +204,18 @@ int main(int argc, char *argv[] ){ int do_safe_checks(){ if( (sizeof(u32) != 4) || (sizeof(u16) != 2) || (sizeof(u8) != 1) ) nping_fatal(QT_3,"Types u32, u16 and u8 do not have the correct sizes on your system."); +#ifdef LINUX + /* Check for WSL and warn that things may not go well. */ + struct utsname uts; + if (!uname(&uts)) { + if (strstr(uts.release, "Microsoft") != NULL) { + error("Warning: %s may not work correctly on Windows Subsystem for Linux.\n" + "For best performance and accuracy, use the native Windows build from %s/download.html#windows.", + NPING_NAME, NPING_URL); + } + } +#endif + test_stuff(); /* Little function that is called quite early to test some misc stuff. */ return OP_SUCCESS; } /* End of do_safe_checks() */