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!")] 15 // In Travis on i686-unknown-linux-musl, this test gets SIGABRT. I don't 16 // know why. It doesn't happen on any other target, and it doesn't happen 17 // on my PC. 18 #[cfg_attr(all(target_env = "musl", target_arch = "x86"), ignore)] test_double_close()19 fn test_double_close() { 20 let m = posix_openpt(OFlag::O_RDWR).unwrap(); 21 close(m.as_raw_fd()).unwrap(); 22 drop(m); // should panic here 23 } 24 } 25