1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::io::Result;

use tokio::process::Command;

use super::{TokioCommandWrap, TokioCommandWrapper};

/// Shim wrapper which sets kill-on-drop on a `Command`.
///
/// This wrapper exists to be able to set the kill-on-drop flag on a `Command` and also store that
/// fact in the wrapper, so that it can be used by other wrappers. Notably this is used by the
/// `JobObject` wrapper.
#[derive(Clone, Copy, Debug)]
pub struct KillOnDrop;

impl TokioCommandWrapper for KillOnDrop {
	fn pre_spawn(&mut self, command: &mut Command, _core: &TokioCommandWrap) -> Result<()> {
		command.kill_on_drop(true);
		Ok(())
	}
}