From 3970601f71d20c836406b8e767e0fa781b81db09 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 23 Sep 2026 13:50:08 +0800 Subject: [PATCH] fix(flutter): keep SIGPIPE setup in the native FFI entry Sciter already receives SIGPIPE initialization from the Rust runtime. Scope the missing startup initialization to native Flutter runners on Linux and macOS. --- src/core_main.rs | 10 ---------- src/flutter.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core_main.rs b/src/core_main.rs index f4dce0258..b5a451ed8 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -30,16 +30,6 @@ macro_rules! my_println{ /// If it returns [`Some`], then the process will continue, and flutter gui will be started. #[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn core_main() -> Option> { - #[cfg(any(target_os = "linux", target_os = "macos"))] - { - use hbb_common::libc; - - // Flutter's native runners bypass Rust's startup, which normally ignores SIGPIPE. - if unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) } == libc::SIG_ERR { - eprintln!("Failed to ignore SIGPIPE: {}", std::io::Error::last_os_error()); - std::process::exit(1); - } - } if !crate::common::global_init() { return None; } diff --git a/src/flutter.rs b/src/flutter.rs index 5c453d468..cd1f1567d 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -105,6 +105,16 @@ fn load_plugin_in_app_path(dll_name: &str) -> Result { #[cfg(not(windows))] #[no_mangle] pub extern "C" fn rustdesk_core_main() -> bool { + #[cfg(any(target_os = "linux", target_os = "macos"))] + { + use hbb_common::libc; + + // Native runners bypass Rust's startup, which normally ignores SIGPIPE. + if unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) } == libc::SIG_ERR { + eprintln!("Failed to ignore SIGPIPE: {}", std::io::Error::last_os_error()); + std::process::exit(1); + } + } #[cfg(not(any(target_os = "android", target_os = "ios")))] if crate::core_main::core_main().is_some() { return true;