Struct ptyprocess::PtyProcess [−][src]
pub struct PtyProcess { /* fields omitted */ }
Expand description
PtyProcess represents a controller for a spawned process.
The structure implements std::io::Read
and std::io::Write
which communicates with
a child.
use ptyprocess::PtyProcess; use std::io::Write; use std::process::Command; let mut process = PtyProcess::spawn(Command::new("cat")).unwrap(); process.write_all(b"Hello World").unwrap(); process.flush().unwrap();
Implementations
Spawns a child process and
creates a PtyProcess
structure which controll communication with a child
let proc = PtyProcess::spawn(Command::new("bash"));
Returns a file representation of a PTY, which can be used to communicate with it.
use ptyprocess::PtyProcess; use std::{process::Command, io::{BufReader, LineWriter}}; let mut process = PtyProcess::spawn(Command::new("cat")).unwrap(); let pty = process.get_pty_handle().unwrap(); let mut writer = LineWriter::new(&pty); let mut reader = BufReader::new(&pty);
Get window size of a terminal.
Default is size is 80x24.
Waits until a echo settings were setup
Set the pty process’s terminate approach delay.
Status returns a status a of child process.
Kill sends a signal to a child process.
The operation is non-blocking.
Wait blocks until a child process exits.
It returns a error if the child was DEAD or not exist
at the time of a call.
So sometimes it’s better to use a is_alive
method
Checks if a process is still exists.
It’s a non blocking operation. It’s takes in mind errors which indicates that the child is gone.
Send writes a string to a STDIN of a child.
Send writes a line to a STDIN of a child.
Send controll character to a child process.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PtyProcess
impl Send for PtyProcess
impl Sync for PtyProcess
impl Unpin for PtyProcess
impl UnwindSafe for PtyProcess