mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-10-21 05:21:17 +00:00
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.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include <dlfcn.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@@ -67,12 +66,6 @@ bool flutter_rustdesk_core_main() {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// This C++ entry point bypasses Rust's SIGPIPE initialization. A closed IPC
|
||||
// peer must produce EPIPE, not terminate the server before Rust handles it.
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
perror("Failed to ignore SIGPIPE");
|
||||
return 1;
|
||||
}
|
||||
if (!flutter_rustdesk_core_main()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,16 @@ fn load_plugin_in_app_path(dll_name: &str) -> Result<Library, LibError> {
|
||||
#[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;
|
||||
|
||||
Reference in New Issue
Block a user