fix: use named pipe probe for IPC availability on Windows (#21)

This commit is contained in:
adarwoo 2026-03-19 15:59:08 +01:00 committed by GitHub
parent fd02c6f3db
commit af516256fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -4225,6 +4225,20 @@ fn ipc_path_from_uri(socket_uri: &str) -> Option<PathBuf> {
fn is_missing_ipc_socket(socket_uri: &str) -> bool { fn is_missing_ipc_socket(socket_uri: &str) -> bool {
if let Some(path) = ipc_path_from_uri(socket_uri) { 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(); return !path.exists();
} }