allow using a TokioCommandWrap for TokioChildProcess::new closes #243 (#245)

* allow using a TokioCommandWrap for TokioChildProcess::new closes #243

TokioCommandWrap implements From<tokio::process::Command> so this is not a breaking change, but also downstream users have more control over flags such as KillOnDrop and CreationFlags

see https://docs.rs/process-wrap/latest/process_wrap/#killondrop-and-creationflags
This commit is contained in:
Lucas Nogueira 2025-06-07 11:59:15 -03:00 committed by GitHub
parent 37b4ddb35d
commit db03f63e76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,11 +59,12 @@ impl AsyncRead for TokioChildProcessOut {
}
impl TokioChildProcess {
pub fn new(mut command: tokio::process::Command) -> std::io::Result<Self> {
command
pub fn new(command: impl Into<TokioCommandWrap>) -> std::io::Result<Self> {
let mut command_wrap = command.into();
command_wrap
.command_mut()
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped());
let mut command_wrap = TokioCommandWrap::from(command);
#[cfg(unix)]
command_wrap.wrap(process_wrap::tokio::ProcessGroup::leader());
#[cfg(windows)]