assay_core/kill_switch/
mod.rs1pub mod capture;
2pub mod incident;
3pub mod killer;
4
5use std::path::PathBuf;
6use std::time::Duration;
7
8#[derive(Debug, Clone)]
9pub enum KillMode {
10 Immediate,
12 Graceful { grace: Duration },
14}
15
16#[derive(Debug, Clone)]
17pub struct KillRequest {
18 pub pid: u32,
19 pub mode: KillMode,
20 pub kill_children: bool,
21 pub capture_state: bool,
22 pub output_dir: Option<PathBuf>, pub reason: Option<String>,
24}
25
26#[derive(Debug, Clone)]
27pub struct KillReport {
28 pub pid: u32,
29 pub success: bool,
30 pub children_killed: Vec<u32>,
31 pub incident_dir: Option<PathBuf>,
32 pub error: Option<String>,
33}
34
35pub fn kill_pid(req: KillRequest) -> anyhow::Result<KillReport> {
36 killer::kill_pid(req)
37}
38
39pub fn parse_target_to_pid(s: &str) -> Option<u32> {
41 if let Some(rest) = s.strip_prefix("proc-") {
42 return rest.parse().ok();
43 }
44 s.parse().ok()
45}