forked from nix-rust/nix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PtyMaster::drop should panic on EBADF
Fixes nix-rust#659
- Loading branch information
Showing
4 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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!")] | ||
fn test_double_close() { | ||
let m = posix_openpt(O_RDWR).unwrap(); | ||
close(m.as_raw_fd()).unwrap(); | ||
drop(m); // should panic here | ||
} |