process_wrap/tokio/kill_on_drop.rs
1use std::io::Result;
2
3use tokio::process::Command;
4
5use super::{CommandWrap, CommandWrapper};
6
7/// Shim wrapper which sets kill-on-drop on a `Command`.
8///
9/// This wrapper exists to be able to set the kill-on-drop flag on a `Command` and also store that
10/// fact in the wrapper, so that it can be used by other wrappers. Notably this is used by the
11/// `JobObject` wrapper.
12#[derive(Clone, Copy, Debug)]
13pub struct KillOnDrop;
14
15impl CommandWrapper for KillOnDrop {
16 fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> {
17 command.kill_on_drop(true);
18 Ok(())
19 }
20}