From 29c1c417ded2f1e06dbe6b6c67288b1bcbe27d60 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 14 Sep 2025 12:04:51 +0800 Subject: chore: ignore most signals --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/client/main.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e640bde..0a27afe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -791,6 +791,7 @@ name = "remote-control-rs" version = "0.1.0" dependencies = [ "reqwest", + "signal-hook", "tokio", "url", ] @@ -1003,6 +1004,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.6" diff --git a/Cargo.toml b/Cargo.toml index 8c9eece..ef32d82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" tokio = { version = "1", features = ["full"] } reqwest = { version = "0.12", features = ["blocking"] } url = { version = "2" } +signal-hook = "0.3.18" [[bin]] name = "client" diff --git a/src/client/main.rs b/src/client/main.rs index 1062ea3..3ef11cc 100644 --- a/src/client/main.rs +++ b/src/client/main.rs @@ -1,10 +1,39 @@ #![feature(associated_type_defaults, never_type)] use crate::connector::{connectors::httpconnector::HTTPConnector, manager::ConnectorManager}; +use signal_hook::consts::signal::*; +use signal_hook::iterator::Signals; + mod connector; mod executor; fn main() { + _ = Signals::new(&[ + SIGHUP, + SIGINT, + SIGQUIT, + SIGTRAP, + SIGABRT, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGUSR1, + SIGUSR2, + SIGCHLD, + SIGCONT, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + #[cfg(any(target_os = "linux", target_os = "android"))] + SIGSYS, + ]); // discard err + let ip = "http://127.0.0.1:8080"; ConnectorManager::new(HTTPConnector::new(ip, ip).unwrap()).enter_loop(); } -- cgit v1.2.3