From cb611ab3142ccf3c76b2c277ede8f8c539369f67 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 16 Jul 2020 02:35:24 -0400 Subject: move all of the logic into the spawn method keep the command class as a pure builder --- examples/basic.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') 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); -- cgit v1.2.3-54-g00ecf