diff options
Diffstat (limited to 'test/test_pty.rs')
-rw-r--r-- | test/test_pty.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_pty.rs b/test/test_pty.rs index 53e94724..55316ab4 100644 --- a/test/test_pty.rs +++ b/test/test_pty.rs @@ -1,5 +1,7 @@ +use std::io::Write; use std::path::Path; use std::os::unix::prelude::*; +use tempfile::tempfile; use nix::fcntl::{O_RDWR, open}; use nix::pty::*; @@ -7,6 +9,20 @@ use nix::sys::stat; use nix::sys::termios::*; use nix::unistd::{write, close}; +/// Regression test for Issue #659 +/// This is the correct way to explicitly close a PtyMaster +#[test] +fn test_explicit_close() { + let mut f = { + let m = posix_openpt(O_RDWR).unwrap(); + close(m.into_raw_fd()).unwrap(); + tempfile().unwrap() + }; + // This should work. But if there's been a double close, then it will + // return EBADF + f.write(b"whatever").unwrap(); +} + /// Test equivalence of `ptsname` and `ptsname_r` #[test] #[cfg(any(target_os = "android", target_os = "linux"))] |