Skip to content

Commit 0260f21

Browse files
oech3sylvestre
authored andcommitted
libstdbuf: remove eprintln! causing 2>/dev/full abort
1 parent cd50566 commit 0260f21

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use ctor::ctor;
88
use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t};
9-
use std::env;
10-
use std::ptr;
9+
use std::io::{Write, stderr};
10+
use std::{env, ptr};
1111

1212
// This runs automatically when the library is loaded via LD_PRELOAD
1313
#[ctor]
@@ -210,7 +210,7 @@ fn set_buffer(stream: *mut FILE, value: &str) {
210210
"L" => (_IOLBF, 0_usize),
211211
input => {
212212
let Ok(buff_size) = input.parse::<usize>() else {
213-
eprintln!("failed to allocate a {value} byte stdio buffer");
213+
let _ = writeln!(stderr(), "failed to allocate a {value} byte stdio buffer");
214214
std::process::exit(1);
215215
};
216216
(_IOFBF, buff_size as size_t)
@@ -223,9 +223,11 @@ fn set_buffer(stream: *mut FILE, value: &str) {
223223
res = libc::setvbuf(stream, buffer, mode, size);
224224
}
225225
if res != 0 {
226-
eprintln!("could not set buffering of {} to mode {mode}", unsafe {
227-
fileno(stream)
228-
});
226+
let _ = writeln!(
227+
stderr(),
228+
"could not set buffering of {} to mode {mode}",
229+
unsafe { fileno(stream) }
230+
);
229231
}
230232
}
231233

0 commit comments

Comments
 (0)