From 6bd3be2e45da9d5c1fac153a6fa37e828e875597 Mon Sep 17 00:00:00 2001 From: 29 <791603901@qq.com> Date: Fri, 10 Jan 2025 19:35:13 +0800 Subject: [PATCH] process: add `Command::get_kill_on_drop()` (#7086) --- 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..565795ac4e6 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 {