running_process/
process_tree.rs1#[cfg(any(test, feature = "async-process"))]
7use std::time::Duration;
8
9pub use running_process_platform_internal::platform::process::kill_tree;
10
11#[cfg(feature = "async-process")]
13pub async fn kill_tree_async(pid: u32, timeout: Duration) -> std::io::Result<u32> {
14 crate::blocking_island::dispatch(move || kill_tree(pid, timeout))
15 .await
16 .map_err(std::io::Error::from)?
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
24 fn missing_pid_is_a_successful_noop() {
25 assert_eq!(kill_tree(u32::MAX, Duration::ZERO).unwrap(), 0);
26 }
27
28 #[cfg(feature = "async-process")]
29 #[tokio::test]
30 async fn missing_pid_is_a_successful_noop_on_the_async_form() {
31 assert_eq!(kill_tree_async(u32::MAX, Duration::ZERO).await.unwrap(), 0);
32 }
33}