]> git.ipfire.org Git - thirdparty/coreutils.git/commit
tail: exit promptly when output no longer writable
authorPádraig Brady <P@draigBrady.com>
Wed, 7 Jun 2017 08:00:28 +0000 (01:00 -0700)
committerPádraig Brady <P@draigBrady.com>
Sun, 11 Jun 2017 22:05:14 +0000 (15:05 -0700)
commitce0415fda108b7ec35181118fd7a2c9ee70331ee
treeb690190c66335f423b86e06520771d184c435d94
parent28042c4ff56ce1c22d620d3a3b0d6f52d98dd0e9
tail: exit promptly when output no longer writable

This will support use cases like:

  tail -f file.log | grep -q trigger &&
  process_immediately

* src/tail.c (check_output_alive): A new function that
uses select on fifos or pipes to detect if they're broken.
(tail_forever): Call check_output_alive() periodically.
(tail_forever_inotify): Merge the select() call from
check_output_alive() into the select() originally present
for the --pid case, and adjust accordingly.
* tests/tail-2/pipe-f.sh: Add test cases.
* NEWS: Mention the improvement.
NEWS
src/tail.c
tests/tail-2/pipe-f.sh