From 2c040c0f329f4212f5769a11664ec95ba7ea84ac Mon Sep 17 00:00:00 2001 From: 29 <791603901@qq.com> Date: Fri, 10 Jan 2025 17:39:28 +0800 Subject: [PATCH 1/2] process: add `Command::get_kill_on_drop()` --- tokio/src/process/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 3077c4edc90..1d839bcf8cd 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -981,6 +981,26 @@ impl Command { async { child?.wait_with_output().await } } + + /// Returns the boolean value that was previously set by [`Command::kill_on_drop`]. + /// + /// Note that if you have not previously called [`Command:: kill_on_drop`], the + /// default value of `false` will be returned here. + /// + /// # Examples + /// + /// ``` + /// use tokio::process::Command; + /// + /// let mut cmd = Command::new("echo"); + /// assert!(!cmd.get_kill_on_drop()); + /// + /// cmd.kill_on_drop(true); + /// assert!(cmd.get_kill_on_drop()); + /// ``` + pub fn get_kill_on_drop(&self) -> bool { + self.kill_on_drop + } } impl From for Command { From 7317aaa6e81507dbe1f498d7c4b8e511c4b1f4a7 Mon Sep 17 00:00:00 2001 From: 29 <791603901@qq.com> Date: Fri, 10 Jan 2025 17:58:54 +0800 Subject: [PATCH 2/2] update doc comment Co-authored-by: Alice Ryhl --- tokio/src/process/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 1d839bcf8cd..565795ac4e6 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -984,7 +984,7 @@ impl Command { /// Returns the boolean value that was previously set by [`Command::kill_on_drop`]. /// - /// Note that if you have not previously called [`Command:: kill_on_drop`], the + /// Note that if you have not previously called [`Command::kill_on_drop`], the /// default value of `false` will be returned here. /// /// # Examples