Skip to content

tail: fix --pid with FIFO by using non-blocking open#9663

Merged
sylvestre merged 4 commits intouutils:mainfrom
ChrisDryden:test-pid-pipe-fix
Jan 10, 2026
Merged

tail: fix --pid with FIFO by using non-blocking open#9663
sylvestre merged 4 commits intouutils:mainfrom
ChrisDryden:test-pid-pipe-fix

Conversation

@ChrisDryden
Copy link
Collaborator

@ChrisDryden ChrisDryden commented Dec 15, 2025

When I was looking into the different tests related to tail that were still failing, I came across the pipe-pid test and when running it, it would hang. When investigating the test I found that it required the file to be opened using a specific flag similar to what was implemented in stty, "Non-blocking open" but only if it was FIFO mode.

I added the code that does this as a helper dependent on the platform, and added a test that validates that when its FIFO that when the monitored process dies, tail is no longer blocking and exits.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

@ChrisDryden ChrisDryden marked this pull request as ready for review December 15, 2025 17:16
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

// Clear O_NONBLOCK so reads block normally
if let Ok(flags) = fcntl(file.as_fd(), FcntlArg::F_GETFL) {
let new_flags = OFlag::from_bits_truncate(flags) & !OFlag::O_NONBLOCK;
let _ = fcntl(file.as_fd(), FcntlArg::F_SETFL(new_flags));
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should handle the error here, no ?

observer.add_bad_path(path, input.display_name.as_str(), false)?;
} else {
match File::open(path) {
let open_result = open_file(path, settings.pid != 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should get ride of open_file for windows
and just call File::open(path)

so, something like

Suggested change
let open_result = open_file(path, settings.pid != 0);
#[cfg(unix)]
let open_result = open_file(path, settings.pid != 0);
#[cfg(not(unix))]
let open_result = File::open(path);

and remove open_file for windows only

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

@sylvestre sylvestre merged commit 3441de9 into uutils:main Jan 10, 2026
132 checks passed
mattsu2020 pushed a commit to mattsu2020/coreutils that referenced this pull request Jan 23, 2026
* tail: fix --pid with FIFO by using non-blocking open

* Address review comments: propagate fcntl errors and remove Windows stub

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Sylvestre Ledru <sylvestre.ledru@gmail.com>
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.

2 participants