process: add Command::get_kill_on_drop() (#7086)

This commit is contained in:
29
2025-01-10 12:35:13 +01:00
committed by GitHub
parent 6fc1a8c8da
commit 6bd3be2e45
+20
View File
@@ -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<StdCommand> for Command {