aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-07-16 02:35:24 -0400
committerJesse Luehrs <doy@tozt.net>2020-07-16 02:35:24 -0400
commitcb611ab3142ccf3c76b2c277ede8f8c539369f67 (patch)
treeb5f127ce5580c7f0e82e1b00f27ecf7b6ceacd1f /examples
parentb5497aa57978aa977de2848617a6d73ab2ee39ff (diff)
downloadpty-process-cb611ab3142ccf3c76b2c277ede8f8c539369f67.tar.gz
pty-process-cb611ab3142ccf3c76b2c277ede8f8c539369f67.zip
move all of the logic into the spawn method
keep the command class as a pure builder
Diffstat (limited to 'examples')
-rw-r--r--examples/basic.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/basic.rs b/examples/basic.rs
index 39ef088..6082b09 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -6,7 +6,7 @@ fn main() {
// cmd.args(&["--color=auto"]);
let mut child = cmd.spawn().unwrap();
let mut buf = [0_u8; 4096];
- let pty = cmd.pty().as_raw_fd();
+ let pty = child.pty().as_raw_fd();
let stdin = std::io::stdin().as_raw_fd();
loop {
let mut set = nix::sys::select::FdSet::new();
@@ -17,7 +17,7 @@ fn main() {
Ok(n) => {
if n > 0 {
if set.contains(pty) {
- match cmd.pty().read(&mut buf) {
+ match child.pty().read(&mut buf) {
Ok(bytes) => {
let buf = &buf[..bytes];
print!(
@@ -37,7 +37,7 @@ fn main() {
match std::io::stdin().read(&mut buf) {
Ok(bytes) => {
let buf = &buf[..bytes];
- cmd.pty().write_all(buf).unwrap();
+ child.pty().write_all(buf).unwrap();
}
Err(e) => {
eprintln!("stdin read failed: {:?}", e);