pub struct Process { /* private fields */ }
Expand description
The structure is resposible for interations with spawned process. It handles IO and other operations related to a spawned process.
Implementations§
source§impl Process
impl Process
sourcepub fn spawn(command: Command) -> Result<Self, Error>
pub fn spawn(command: Command) -> Result<Self, Error>
Spawn a given command.
ⓘ
use std::io::prelude::*;
use std::process::Command;
use conpty::Process;
let mut cmd = Command::new("cmd");
cmd.args(&["/C", "echo Hello World"]);
let mut proc = Process::spawn(cmd).unwrap();
let mut reader = proc.output().unwrap();
let mut buf = [0; 1028];
let n = reader.read(&mut buf).unwrap();
assert!(String::from_utf8_lossy(&buf).contains("Hello World"));
sourcepub fn wait(&self, timeout_millis: Option<u32>) -> Result<u32, Error>
pub fn wait(&self, timeout_millis: Option<u32>) -> Result<u32, Error>
Waits before process exists.
sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Is alive determines if a process is still running.
IMPORTANT: Beware to use it in a way to stop reading when is_alive is false.
sourcepub fn input(&mut self) -> Result<PipeWriter, Error>
pub fn input(&mut self) -> Result<PipeWriter, Error>
Returns a pipe writer to conPTY.
sourcepub fn output(&mut self) -> Result<PipeReader, Error>
pub fn output(&mut self) -> Result<PipeReader, Error>
Returns a pipe reader from conPTY.