Skip to content

Commit 61e83a1

Browse files
committed
tail: fix intermittent overlay-headers test by batching inotify events
1 parent 67ede85 commit 61e83a1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/uu/tail/src/follow/watch.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,17 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> {
576576
// Drain any additional pending events to batch them together.
577577
// This prevents redundant headers when multiple inotify events
578578
// are queued (e.g., after resuming from SIGSTOP).
579-
while let Ok(Ok(event)) = observer.watcher_rx.as_mut().unwrap().receiver.try_recv()
580-
{
581-
process_event(&mut observer, event, settings, &mut paths)?;
579+
// Multiple iterations with spin_loop hints give the notify
580+
// background thread chances to deliver pending events.
581+
for _ in 0..100 {
582+
while let Ok(Ok(event)) =
583+
observer.watcher_rx.as_mut().unwrap().receiver.try_recv()
584+
{
585+
process_event(&mut observer, event, settings, &mut paths)?;
586+
}
587+
// Use both yield and spin hint for broader CPU support
588+
std::thread::yield_now();
589+
std::hint::spin_loop();
582590
}
583591
}
584592
Ok(Err(notify::Error {

0 commit comments

Comments
 (0)