diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-16 05:08:06 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-07-16 05:08:06 +0000 |
commit | 5d296505b597d29bf6b339904f7f1550febe863d (patch) | |
tree | 4c493ed698e5f68a58603643cf7db1daed284d2f /test/test_ptymaster_drop.rs | |
parent | f84a008559d4f8ce0a79652ad0c515e7139a272c (diff) | |
parent | 5fb4cebcc6c9b241668d36c8732c93e1978b135e (diff) | |
download | nix-5d296505b597d29bf6b339904f7f1550febe863d.zip |
Merge #677
677: PtyMaster::drop should panic on EBADF r=asomers
Fixes #659
Diffstat (limited to 'test/test_ptymaster_drop.rs')
-rw-r--r-- | test/test_ptymaster_drop.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_ptymaster_drop.rs b/test/test_ptymaster_drop.rs new file mode 100644 index 00000000..664a4dd6 --- /dev/null +++ b/test/test_ptymaster_drop.rs @@ -0,0 +1,21 @@ +extern crate nix; + +use nix::fcntl::O_RDWR; +use nix::pty::*; +use nix::unistd::close; +use std::os::unix::io::AsRawFd; + +/// Regression test for Issue #659 +/// PtyMaster should panic rather than double close the file descriptor +/// This must run in its own test process because it deliberately creates a race +/// condition. +#[test] +#[should_panic(expected = "Closing an invalid file descriptor!")] +// In Travis on i686-unknown-linux-musl, this test gets SIGABRT. I don't know +// why. It doesn't happen on any other target, and it doesn't happen on my PC. +#[cfg_attr(all(target_env = "musl", target_arch = "x86"), ignore)] +fn test_double_close() { + let m = posix_openpt(O_RDWR).unwrap(); + close(m.as_raw_fd()).unwrap(); + drop(m); // should panic here +} |