You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tail /dev/null --pid 0 --follow should open /dev/null with O_NONBLOCK #13109
Two things beyond the title worth calling out, since they change what the fix needs to be:
It isn't FIFO-specific, and it isn't cleared afterward. GNU sets O_NONBLOCK on any file — a plain regular file, not just /dev/null — whenever --pid is given, and it stays set: I only see fcntl(F_GETFL) calls after the open, never an F_SETFL that clears it. That's a different design from what's in open_file, which only applies O_NONBLOCK to FIFOs, and deliberately clears it right after opening so every subsequent read blocks normally — see the doc comment above it.
--pid 0 should behave the same as any other pid. The call site passes settings.pid.is_some_and(|pid| pid != 0) (tail.rs:167), which excludes 0 on purpose — that's the exact case in the issue title. I checked GNU with --pid 0 and --pid 99999 side by side; both get O_NONBLOCK, so the exclusion doesn't match GNU here.
Why I haven't opened a PR for this one: widening the condition to "any file, pid including 0" is a one-line change, but doing that without anything else would be wrong — the reasonopen_file clears O_NONBLOCK today is that nothing downstream in the follow loop handles EAGAIN/WouldBlock (I grepped, there's no handling anywhere in src/uu/tail). If a read genuinely returns WouldBlock — which it now could, on a FIFO or pipe with no writer ready — the current code has nowhere for that to go. GNU's own --pid polling loop is built around exactly that (O_NONBLOCK + retry on EAGAIN), so matching it properly means adding that handling, not just moving where the flag is set. Since this touches the follow loop's error handling rather than being a pure one-liner, it felt like something to describe rather than guess at blind.
Happy to build it either way a maintainer prefers — replicate GNU's persistent-O_NONBLOCK-plus-retry shape, or leave the current clear-after-open design (which is safe) and just fix the pid != 0 exclusion as a smaller, lower-risk step.
Investigated with AI assistance (Claude Opus 5, via Claude Code); GNU's behaviour was confirmed with strace against the installed GNU 9.11 binary.
Activity
arbelonson-source commentedon Aug 30, 2026
Confirmed with
strace(GNU 9.11, glibc):Two things beyond the title worth calling out, since they change what the fix needs to be:
It isn't FIFO-specific, and it isn't cleared afterward. GNU sets
O_NONBLOCKon any file — a plain regular file, not just/dev/null— whenever--pidis given, and it stays set: I only seefcntl(F_GETFL)calls after theopen, never anF_SETFLthat clears it. That's a different design from what's inopen_file, which only appliesO_NONBLOCKto FIFOs, and deliberately clears it right after opening so every subsequent read blocks normally — see the doc comment above it.--pid 0should behave the same as any other pid. The call site passessettings.pid.is_some_and(|pid| pid != 0)(tail.rs:167), which excludes0on purpose — that's the exact case in the issue title. I checked GNU with--pid 0and--pid 99999side by side; both getO_NONBLOCK, so the exclusion doesn't match GNU here.Why I haven't opened a PR for this one: widening the condition to "any file, pid including 0" is a one-line change, but doing that without anything else would be wrong — the reason
open_fileclearsO_NONBLOCKtoday is that nothing downstream in the follow loop handlesEAGAIN/WouldBlock(I grepped, there's no handling anywhere insrc/uu/tail). If a read genuinely returnsWouldBlock— which it now could, on a FIFO or pipe with no writer ready — the current code has nowhere for that to go. GNU's own--pidpolling loop is built around exactly that (O_NONBLOCK+ retry onEAGAIN), so matching it properly means adding that handling, not just moving where the flag is set. Since this touches the follow loop's error handling rather than being a pure one-liner, it felt like something to describe rather than guess at blind.Happy to build it either way a maintainer prefers — replicate GNU's persistent-
O_NONBLOCK-plus-retry shape, or leave the current clear-after-open design (which is safe) and just fix thepid != 0exclusion as a smaller, lower-risk step.Investigated with AI assistance (Claude Opus 5, via Claude Code); GNU's behaviour was confirmed with
straceagainst the installed GNU 9.11 binary.tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid
tail: keep named inputs nonblocking with --pid (uutils#15479)