diff --git a/tokio/src/process/unix/mod.rs b/tokio/src/process/unix/mod.rs index 2b82c33f146..b1391bb51c9 100644 --- a/tokio/src/process/unix/mod.rs +++ b/tokio/src/process/unix/mod.rs @@ -132,20 +132,16 @@ impl Drop for ChildDropGuard { impl ChildDropGuard { pub(crate) fn new(child: StdChild) -> ChildDropGuard { - return ChildDropGuard { + ChildDropGuard { child: Some(child), kill_on_drop: true, - }; + } } pub(crate) fn extract(mut self) -> StdChild { self.child.take().unwrap() } - pub(crate) fn dont_kill_on_drop(&mut self) { - self.kill_on_drop = false; - } - pub(crate) fn take_stdin(&mut self) -> Option { self.child .as_mut() @@ -168,6 +164,12 @@ impl ChildDropGuard { .take() } + #[cfg(all(target_os = "linux", feature = "rt"))] + pub(crate) fn dont_kill_on_drop(&mut self) { + self.kill_on_drop = false; + } + + #[cfg(all(target_os = "linux", feature = "rt"))] pub(crate) fn inner_mut(&mut self) -> &mut StdChild { self.child.as_mut().expect("child has gone away") }