tail: fix --pid with FIFO by using non-blocking open#9663
Merged
sylvestre merged 4 commits intouutils:mainfrom Jan 10, 2026
Merged
tail: fix --pid with FIFO by using non-blocking open#9663sylvestre merged 4 commits intouutils:mainfrom
sylvestre merged 4 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
88b73b3 to
a6b348e
Compare
|
GNU testsuite comparison: |
This was referenced Dec 15, 2025
|
GNU testsuite comparison: |
sylvestre
reviewed
Jan 9, 2026
src/uu/tail/src/tail.rs
Outdated
| // 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)); |
Contributor
There was a problem hiding this comment.
i think we should handle the error here, no ?
sylvestre
reviewed
Jan 9, 2026
| 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); |
Contributor
There was a problem hiding this comment.
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
|
GNU testsuite comparison: |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.