summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-14 12:04:51 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-14 12:04:51 +0800
commit29c1c417ded2f1e06dbe6b6c67288b1bcbe27d60 (patch)
treeacf50751223514cb9d525861e43f9a7dfe75a0f9
parent6e18f17b727b3bec2edf46c1bcbb16f80983397e (diff)
chore: ignore most signals
-rw-r--r--Cargo.lock11
-rw-r--r--Cargo.toml1
-rw-r--r--src/client/main.rs29
3 files changed, 41 insertions, 0 deletions
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",
]
@@ -1004,6 +1005,16 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
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();
}