pty-process
This crate adds a helper method to std::process::Command
(and optionally its
equivalent in various async frameworks) to allocate a pty to spawn the process
into. This allows for manipulation of interactive programs.
The basic functionality is provided by the Command
trait in this crate:
use Command as _;
let mut cmd = new;
let child = cmd.spawn_pty.unwrap;
The child
instance returned by the call to spawn_pty
is a thin wrapper
around the Child
struct associated with the Command
module used. You can
use it identically to how you would use the normal std::process::Child
instance, but it also provides additional methods for interacting with the pty:
use Write as _;
child.pty.write_all.unwrap;
child.resize_pty.unwrap;
let status = child.wait.unwrap;
The available implementations are gated by features:
backend-std
: Add an implementation forstd::process::Command
. Enabled by default.backend-smol
: Add an implementation forsmol::process::Command
.backend-async-std
: Add an implementation forasync_std::process::Command
.backend-tokio
: Add an implementation fortokio::process::Command
.
Any number of backends may be enabled, depending on your needs.