From af516256fbeba7b3e137ffb6ee047e9e6ab54476 Mon Sep 17 00:00:00 2001 From: adarwoo <44254473+adarwoo@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:59:08 +0100 Subject: [PATCH] fix: use named pipe probe for IPC availability on Windows (#21) --- src/client.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/client.rs b/src/client.rs index d81a1f6..63f8b80 100644 --- a/src/client.rs +++ b/src/client.rs @@ -4225,6 +4225,20 @@ fn ipc_path_from_uri(socket_uri: &str) -> Option { fn is_missing_ipc_socket(socket_uri: &str) -> bool { if let Some(path) = ipc_path_from_uri(socket_uri) { + #[cfg(target_os = "windows")] + { + // On Windows, nng's ipc:// transport uses named pipes, not filesystem + // sockets. A path.exists() check is always false even when KiCad is + // running. Instead, probe the named pipe directly: a successful open + // or ERROR_PIPE_BUSY (231) both mean a server is listening. + let pipe_path = format!(r"\\.\pipe\{}", path.display()); + return match std::fs::OpenOptions::new().read(true).open(&pipe_path) { + Ok(_) => false, + Err(e) => e.raw_os_error() != Some(231), + }; + } + + #[cfg(not(target_os = "windows"))] return !path.exists(); }