Mountain/IPC/WindServiceHandlers/NativeHost/
KillProcess.rs1
2use serde_json::Value;
8
9use crate::dev_log;
10
11pub async fn Fn(Arguments:Vec<Value>) -> Result<Value, String> {
12 let Pid = Arguments.first().and_then(Value::as_u64).unwrap_or(0) as u32;
13
14 if Pid == 0 {
15 return Ok(Value::Null);
16 }
17
18 dev_log!("process", "nativeHost:killProcess pid={}", Pid);
19
20 #[cfg(unix)]
21 {
22 use std::process::Command;
23
24 let _ = Command::new("kill").args(["-9", &Pid.to_string()]).status();
25 }
26
27 #[cfg(windows)]
28 {
29 use std::process::Command;
30
31 let _ = Command::new("taskkill").args(["/F", "/PID", &Pid.to_string()]).status();
32 }
33
34 Ok(Value::Null)
35}