diff options
Diffstat (limited to 'src/command/tokio.rs')
-rw-r--r-- | src/command/tokio.rs | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/command/tokio.rs b/src/command/tokio.rs index 54bfefb..338bc08 100644 --- a/src/command/tokio.rs +++ b/src/command/tokio.rs @@ -1,19 +1,14 @@ -use crate::error::*; +use std::os::unix::io::FromRawFd as _; -use std::os::unix::io::{AsRawFd as _, FromRawFd as _}; - -impl super::Command for tokio::process::Command { +impl super::CommandImpl for tokio::process::Command { type Child = tokio::process::Child; - fn spawn_pty( + fn std_fds( &mut self, - size: Option<&crate::pty::Size>, - ) -> Result<super::Child<Self::Child>> { - let (pty, pts, stdin, stdout, stderr) = super::setup_pty(size)?; - - let pt_fd = pty.pt().as_raw_fd(); - let pts_fd = pts.as_raw_fd(); - + stdin: ::std::os::unix::io::RawFd, + stdout: ::std::os::unix::io::RawFd, + stderr: ::std::os::unix::io::RawFd, + ) { // safe because the fds are valid (otherwise pty.pts() or dup() would // have returned an Err and we would have exited early) and are not // owned by any other structure (since dup() returns a fresh copy of @@ -21,18 +16,21 @@ impl super::Command for tokio::process::Command { self.stdin(unsafe { std::process::Stdio::from_raw_fd(stdin) }) .stdout(unsafe { std::process::Stdio::from_raw_fd(stdout) }) .stderr(unsafe { std::process::Stdio::from_raw_fd(stderr) }); + } + fn pre_exec_impl<F>(&mut self, f: F) + where + F: FnMut() -> ::std::io::Result<()> + Send + Sync + 'static, + { // safe because setsid() and close() are async-signal-safe functions // and ioctl() is a raw syscall (which is inherently // async-signal-safe). unsafe { - self.pre_exec(move || { - super::pre_exec(pt_fd, pts_fd, stdin, stdout, stderr) - }); + self.pre_exec(f); } + } - let child = self.spawn().map_err(Error::Spawn)?; - - Ok(super::Child { child, pty }) + fn spawn_impl(&mut self) -> ::std::io::Result<Self::Child> { + self.spawn() } } |