1 #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))]
2 mod t {
3     use nix::fcntl::OFlag;
4     use nix::pty::*;
5     use nix::unistd::close;
6     use std::os::unix::io::AsRawFd;
7 
8     /// Regression test for Issue #659
9     ///
10     /// `PtyMaster` should panic rather than double close the file descriptor
11     /// This must run in its own test process because it deliberately creates a
12     /// race condition.
13     #[test]
14     #[should_panic(expected = "Closing an invalid file descriptor!")]
test_double_close()15     fn test_double_close() {
16         let m = posix_openpt(OFlag::O_RDWR).unwrap();
17         close(m.as_raw_fd()).unwrap();
18         drop(m);            // should panic here
19     }
20 }
21