Skip to content

uucore::pipes: remove pipe and use pipe_with_size(MAX_ROOTLESS_PIPE_SIZE)#12284

Open
blixygetir wants to merge 2 commits into
uutils:mainfrom
blixygetir:pipe-fix
Open

uucore::pipes: remove pipe and use pipe_with_size(MAX_ROOTLESS_PIPE_SIZE)#12284
blixygetir wants to merge 2 commits into
uutils:mainfrom
blixygetir:pipe-fix

Conversation

@blixygetir
Copy link
Copy Markdown
Contributor

Fixes #12271

I have changes to the files using uucore:pipe replacing it with pipe_size_max(MAX_ROOTLESS_PIPE_SIZE). I've made this function public in the pipe.rs file.

Copilot AI review requested due to automatic review settings May 14, 2026 07:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Linux/Android pipe usage to call pipe_with_size(MAX_ROOTLESS_PIPE_SIZE) directly and makes pipe_with_size public in uucore::pipes.

Changes:

  • Exposes uucore::pipes::pipe_with_size.
  • Replaces selected pipe() usages in yes, wc, and a comm test with pipe_with_size(MAX_ROOTLESS_PIPE_SIZE).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/uucore/src/lib/features/pipes.rs Makes pipe_with_size public.
src/uu/yes/src/yes.rs Uses pipe_with_size(MAX_ROOTLESS_PIPE_SIZE) for fast-path pipes.
src/uu/wc/src/count_fast.rs Uses pipe_with_size(MAX_ROOTLESS_PIPE_SIZE) for splice broker pipe creation.
tests/by-util/test_comm.rs Updates anonymous pipe test to use pipe_with_size(MAX_ROOTLESS_PIPE_SIZE).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to 46
pub fn pipe_with_size(s: usize) -> std::io::Result<(File, File)> {
let (read, write) = rustix::pipe::pipe()?;
if s > KERNEL_DEFAULT_PIPE_SIZE {
let _ = fcntl_setpipe_size(&read, s);
Copy link
Copy Markdown
Contributor

@oech3 oech3 May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is deliberately ignored since it is NOT requirement for splice fast-path. I'll add different fn pipe_exact and change doc later.
Please ignore AI's review.

Comment thread tests/by-util/test_comm.rs Outdated
fn test_comm_anonymous_pipes() {
use std::{io::Write, os::fd::AsRawFd, process};
use uucore::pipes::pipe;
use uucore::pipes::{pipe_with_size, MAX_ROOTLESS_PIPE_SIZE};
#[inline]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn pipe_with_size(s: usize) -> std::io::Result<(File, File)> {
pub fn pipe_with_size(s: usize) -> std::io::Result<(File, File)> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal is blocked by #12284 (comment) .

Comment thread tests/by-util/test_comm.rs Outdated
fn test_comm_anonymous_pipes() {
use std::{io::Write, os::fd::AsRawFd, process};
use uucore::pipes::pipe;
use uucore::pipes::{pipe_with_size, MAX_ROOTLESS_PIPE_SIZE};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For test_comm, we don't need too large pipe. We should rustix::pipe::pipe directly at here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And cfg should be gated to unix too.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 14, 2026

Would you wait merging #12254 ? Then you can remove uucore::pipes::pipe at this PR too.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cut/cut-huge-range is now being skipped but was previously passing.
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.
Note: The gnu test tests/misc/write-errors was skipped on 'main' but is now failing.

@blixygetir
Copy link
Copy Markdown
Contributor Author

Sure

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 14, 2026

Another option is adding const generics to determine changing pipe size is optional or not.
I'll open the PR for it if you are OK.

@blixygetir
Copy link
Copy Markdown
Contributor Author

I think the only difference if I use generics for size would be an ? at the end, separating the functions via the requirement of a size parameter would make the code more readable and explicit.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 14, 2026

opened #12285

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 14, 2026

separating the functions via the requirement of a size parameter would make the code more readable and explicit.

Personally, I don't want to have many rustix::pipe::pipe wrappers mostly doing same things.

@blixygetir
Copy link
Copy Markdown
Contributor Author

Sounds fair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uucore::pipes: remove pipe and use pipe_with_size(MAX_ROOTLESS_PIPE_SIZE)

3 participants