From 68a35e65f228244ebdb5d4ce3ad386eca8292672 Mon Sep 17 00:00:00 2001 From: RustDesk <71636191+rustdesk@users.noreply.github.com> Date: Wed, 23 Sep 2026 14:05:15 +0800 Subject: [PATCH] fix(unix): ignore SIGPIPE in native Flutter entry (#16322) * fix(linux): ignore SIGPIPE in Flutter runner Initialize SIGPIPE before entering the Rust core so writes to closed IPC peers return EPIPE instead of terminating the server. Add a native-entry regression test for the failure reported in #16297. * test(linux): remove SIGPIPE runner test * fix(flutter): initialize SIGPIPE in the Rust native entry Share SIGPIPE initialization between the Linux and macOS native runners before core startup. Remove the Linux C++ initialization. * fix: share SIGPIPE initialization with Sciter startup Initialize SIGPIPE before global_init in core_main, shared by Flutter and Sciter on Linux and macOS. * 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/flutter.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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;