mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Close file descriptors of pipes after use (#2591)
* Close file descriptors of pipes after use * cat: Test file descriptor exhaustion * fixup! cat: Test file descriptor exhaustion
This commit is contained in:
parent
c77115ab51
commit
516c5311f7
3 changed files with 35 additions and 10 deletions
|
@ -1,8 +1,13 @@
|
|||
// spell-checker:ignore NOFILE
|
||||
|
||||
use crate::common::util::*;
|
||||
use std::fs::OpenOptions;
|
||||
#[cfg(unix)]
|
||||
use std::io::Read;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use rlimit::Resource;
|
||||
|
||||
#[test]
|
||||
fn test_output_simple() {
|
||||
new_ucmd!()
|
||||
|
@ -87,6 +92,23 @@ fn test_fifo_symlink() {
|
|||
thread.join().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_closes_file_descriptors() {
|
||||
// Each file creates a pipe, which has two file descriptors.
|
||||
// If they are not closed then five is certainly too many.
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
"alpha.txt",
|
||||
"alpha.txt",
|
||||
"alpha.txt",
|
||||
"alpha.txt",
|
||||
"alpha.txt",
|
||||
])
|
||||
.with_limit(Resource::NOFILE, 9, 9)
|
||||
.succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_piped_to_regular_file() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue