Lines Matching +full:use +full:- +full:pty
1 use std::fs::File;
2 use std::io::{Read, Write};
3 use std::os::unix::prelude::*;
4 use std::path::Path;
5 use tempfile::tempfile;
7 use libc::{_exit, STDOUT_FILENO};
8 use nix::fcntl::{open, OFlag};
9 use nix::pty::*;
10 use nix::sys::stat;
11 use nix::sys::termios::*;
12 use nix::unistd::{close, pause, write};
45 // TODO need to run in a subprocess, since ptsname is non-reentrant
100 fn open_ptty_pair() -> (PtyMaster, File) { in open_ptty_pair()
122 use libc::{ioctl, I_FIND, I_PUSH}; in open_ptty_pair()
150 /// master/slave PTTY pair, then just sanity-check the raw values.
204 let pty = openpty(None, None).unwrap(); in test_openpty() localVariable
205 assert!(pty.master > 0); in test_openpty()
206 assert!(pty.slave > 0); in test_openpty()
211 write(pty.master, string.as_bytes()).unwrap(); in test_openpty()
212 crate::read_exact(pty.slave, &mut buf); in test_openpty()
219 crate::read_exact(pty.master, &mut buf); in test_openpty()
225 write(pty.slave, string2.as_bytes()).unwrap(); in test_openpty()
226 crate::read_exact(pty.master, &mut buf); in test_openpty()
230 close(pty.master).unwrap(); in test_openpty()
231 close(pty.slave).unwrap(); in test_openpty()
239 // Open one pty to get attributes for the second one in test_openpty_with_termios()
241 let pty = openpty(None, None).unwrap(); in test_openpty_with_termios() localVariable
242 assert!(pty.master > 0); in test_openpty_with_termios()
243 assert!(pty.slave > 0); in test_openpty_with_termios()
244 let termios = tcgetattr(pty.slave).unwrap(); in test_openpty_with_termios()
245 close(pty.master).unwrap(); in test_openpty_with_termios()
246 close(pty.slave).unwrap(); in test_openpty_with_termios()
252 let pty = openpty(None, &termios).unwrap(); in test_openpty_with_termios() localVariable
254 assert!(pty.master > 0); in test_openpty_with_termios()
255 assert!(pty.slave > 0); in test_openpty_with_termios()
260 write(pty.master, string.as_bytes()).unwrap(); in test_openpty_with_termios()
261 crate::read_exact(pty.slave, &mut buf); in test_openpty_with_termios()
267 crate::read_exact(pty.master, &mut buf); in test_openpty_with_termios()
273 write(pty.slave, string2.as_bytes()).unwrap(); in test_openpty_with_termios()
274 crate::read_exact(pty.master, &mut buf); in test_openpty_with_termios()
278 close(pty.master).unwrap(); in test_openpty_with_termios()
279 close(pty.slave).unwrap(); in test_openpty_with_termios()
284 use nix::sys::signal::*; in test_forkpty()
285 use nix::sys::wait::wait; in test_forkpty()
286 use nix::unistd::ForkResult::*; in test_forkpty()
294 let pty = unsafe { forkpty(None, None).unwrap() }; in test_forkpty() localVariable
295 match pty.fork_result { in test_forkpty()
306 crate::read_exact(pty.master, &mut buf); in test_forkpty()
310 close(pty.master).unwrap(); in test_forkpty()