Skip to content

sort: avoid reopening non-seekable inputs#13494

Open
wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:sort-fifo-unterminated-line
Open

sort: avoid reopening non-seekable inputs#13494
wtcpython wants to merge 1 commit into
uutils:mainfrom
wtcpython:sort-fifo-unterminated-line

Conversation

@wtcpython

@wtcpython wtcpython commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #13172.

sort pre-opened every input to validate it before opening it again for processing. For a non-seekable input, the validation open could consume the only writer connection; the subsequent open then waited indefinitely for another writer.

When the first seek identifies a non-seekable input, keep that reader open and use it for processing instead of detecting FIFO inputs with metadata. Add a regression test covering an unterminated named FIFO input.

@oech3

oech3 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

FIFO is not stdin only. Also we should detect them as error of 1st seek instead of using stat.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/timeout/timeout-group (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)
Congrats! The gnu test tests/seq/seq-epipe is now passing!

@wtcpython
wtcpython force-pushed the sort-fifo-unterminated-line branch from 195eb27 to c95dab0 Compare July 22, 2026 02:16
@wtcpython wtcpython changed the title sort: avoid pre-opening FIFO inputs sort: avoid reopening non-seekable inputs Jul 22, 2026
Comment thread src/uu/sort/src/sort.rs Outdated
for file in &files {
open(file)?;
// Keep the first non-seekable input open so that validation does not consume it before it is
// read.

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.

How about keep opening everything without checking FIFO?

@wtcpython
wtcpython force-pushed the sort-fifo-unterminated-line branch from c95dab0 to 88c1a2d Compare July 22, 2026 03:27
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.

bug(sort): when the pipe sends $'hello' without any \n, sort ignore the requests

2 participants