aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/std.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/command/std.rs')
-rw-r--r--src/command/std.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/command/std.rs b/src/command/std.rs
index 0f3bef1..b331fc0 100644
--- a/src/command/std.rs
+++ b/src/command/std.rs
@@ -1,20 +1,15 @@
-use crate::error::*;
-
-use std::os::unix::io::{AsRawFd as _, FromRawFd as _};
+use std::os::unix::io::FromRawFd as _;
use std::os::unix::process::CommandExt as _;
-impl super::Command for std::process::Command {
+impl super::CommandImpl for std::process::Command {
type Child = std::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
@@ -22,18 +17,21 @@ impl super::Command for std::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()
}
}