diff options
Diffstat (limited to 'src/pty.rs')
-rw-r--r-- | src/pty.rs | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -1,7 +1,5 @@ //! Create master and slave virtual pseudo-terminals (PTYs) -use libc; - pub use libc::pid_t as SessionId; pub use libc::winsize as Winsize; @@ -10,10 +8,10 @@ use std::io; use std::mem; use std::os::unix::prelude::*; -use sys::termios::Termios; -use unistd::ForkResult; -use {Result, Error, fcntl}; -use errno::Errno; +use crate::sys::termios::Termios; +use crate::unistd::{self, ForkResult, Pid}; +use crate::{Result, Error, fcntl}; +use crate::errno::Errno; /// Representation of a master/slave pty pair /// @@ -71,7 +69,7 @@ impl Drop for PtyMaster { // invalid file descriptor. That frequently indicates a double-close // condition, which can cause confusing errors for future I/O // operations. - let e = ::unistd::close(self.0); + let e = unistd::close(self.0); if e == Err(Error::Sys(Errno::EBADF)) { panic!("Closing an invalid file descriptor!"); }; @@ -80,13 +78,13 @@ impl Drop for PtyMaster { impl io::Read for PtyMaster { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { - ::unistd::read(self.0, buf).map_err(|e| e.as_errno().unwrap().into()) + unistd::read(self.0, buf).map_err(|e| e.as_errno().unwrap().into()) } } impl io::Write for PtyMaster { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { - ::unistd::write(self.0, buf).map_err(|e| e.as_errno().unwrap().into()) + unistd::write(self.0, buf).map_err(|e| e.as_errno().unwrap().into()) } fn flush(&mut self) -> io::Result<()> { Ok(()) @@ -309,8 +307,6 @@ pub fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios> termios: U, ) -> Result<ForkptyResult> { use std::ptr; - use unistd::Pid; - use unistd::ForkResult::*; let mut master = mem::MaybeUninit::<libc::c_int>::uninit(); @@ -332,8 +328,8 @@ pub fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios> }; let fork_result = Errno::result(res).map(|res| match res { - 0 => Child, - res => Parent { child: Pid::from_raw(res) }, + 0 => ForkResult::Child, + res => ForkResult::Parent { child: Pid::from_raw(res) }, })?; unsafe { |