Skip to content

Commit 8a271f5

Browse files
oech3sylvestre
authored andcommitted
yes: avoid ambiguous PAGE_SIZE
1 parent f33bfb9 commit 8a271f5

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/uu/yes/src/yes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ pub fn exec(mut bytes: Vec<u8>) -> io::Result<()> {
110110
use uucore::io::RawWriter;
111111
use uucore::pipes::{pipe, splice, tee};
112112

113-
const PAGE_SIZE: usize = 4096;
114-
let aligned = PAGE_SIZE.is_multiple_of(bytes.len());
113+
let safe_partial_send = rustix::pipe::PIPE_BUF.is_multiple_of(bytes.len());
115114
repeat_content_to_capacity(&mut bytes);
116115
let bytes = bytes.as_slice();
117116
let stdout = rustix::stdio::stdout();
@@ -121,7 +120,7 @@ pub fn exec(mut bytes: Vec<u8>) -> io::Result<()> {
121120
if let Ok((p_read, mut p_write)) = pipe::<true>(MAX_ROOTLESS_PIPE_SIZE)
122121
&& p_write.write_all(bytes).is_ok()
123122
{
124-
if aligned && tee(&p_read, &stdout, MAX_ROOTLESS_PIPE_SIZE).is_ok() {
123+
if safe_partial_send && tee(&p_read, &stdout, MAX_ROOTLESS_PIPE_SIZE).is_ok() {
125124
while let Ok(1..) = tee(&p_read, &stdout, MAX_ROOTLESS_PIPE_SIZE) {}
126125
} else if let Ok((broker_read, broker_write)) = pipe::<true>(MAX_ROOTLESS_PIPE_SIZE) {
127126
// tee() cannot control offset and write to non-pipe

0 commit comments

Comments
 (0)