Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
143 additions
and
26 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
80_tail-2_wait_max-unchanged-stats | ||
81_tail-f- | ||
82_symlink_utimensat_enosys | ||
83_tail_flush |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#! /bin/sh /usr/share/dpatch/dpatch-run | ||
## 83_tail_flush.dpatch by Jim Meyering <meyering@redhat.com> | ||
## | ||
## All lines beginning with `## DP:' are a description of the patch. | ||
## DP: flush initial output before possibly blocking | ||
|
||
@DPATCH@ | ||
diff -urNad coreutils-7.5~/NEWS coreutils-7.5/NEWS | ||
--- coreutils-7.5~/NEWS 2009-09-11 05:56:07.000000000 -0400 | ||
+++ coreutils-7.5/NEWS 2009-09-11 05:56:16.080040689 -0400 | ||
@@ -45,6 +45,11 @@ | ||
nl --page-increment: deprecated in favor of --line-increment, the new option | ||
maintains the previous semantics and the same short option, -i. | ||
|
||
+ tail -f (inotify-enabled) now flushes any initial output before blocking. | ||
+ Before, this would print nothing and wait: stdbuf -o 4K tail -f /etc/passwd | ||
+ Note that this bug affects tail -f only when its standard output is buffered, | ||
+ which is relatively unusual. | ||
+ | ||
** New features | ||
|
||
chroot now accepts the options --userspec and --groups. | ||
diff -urNad coreutils-7.5~/src/tail.c coreutils-7.5/src/tail.c | ||
--- coreutils-7.5~/src/tail.c 2009-09-11 05:56:15.796040675 -0400 | ||
+++ coreutils-7.5/src/tail.c 2009-09-11 05:58:13.367648405 -0400 | ||
@@ -1442,7 +1442,6 @@ | ||
if (fflush (stdout) != 0) | ||
error (EXIT_FAILURE, errno, _("write error")); | ||
} | ||
- | ||
} | ||
#endif | ||
|
||
@@ -2027,6 +2026,12 @@ | ||
error (0, errno, _("inotify cannot be used, reverting to polling")); | ||
else | ||
{ | ||
+ /* Flush any output from tail_file, now, since | ||
+ tail_forever_inotify flushes only after writing, | ||
+ not before reading. */ | ||
+ if (fflush (stdout) != 0) | ||
+ error (EXIT_FAILURE, errno, _("write error")); | ||
+ | ||
tail_forever_inotify (wd, F, n_files, sleep_interval); | ||
|
||
/* The only way the above returns is upon failure. */ | ||
diff -urNad coreutils-7.5~/src/tail.c.rej coreutils-7.5/src/tail.c.rej | ||
--- coreutils-7.5~/src/tail.c.rej 1969-12-31 19:00:00.000000000 -0500 | ||
+++ coreutils-7.5/src/tail.c.rej 2009-09-11 05:56:16.080040689 -0400 | ||
@@ -0,0 +1,21 @@ | ||
+*************** main (int argc, char **argv) | ||
+*** 2033,2038 **** | ||
+ error (0, errno, _("inotify cannot be used, reverting to polling")); | ||
+ else | ||
+ { | ||
+ tail_forever_inotify (wd, F, n_files, sleep_interval); | ||
+ | ||
+ /* The only way the above returns is upon failure. */ | ||
+--- 2032,2043 ---- | ||
+ error (0, errno, _("inotify cannot be used, reverting to polling")); | ||
+ else | ||
+ { | ||
++ /* Flush any output from tail_file, now, since | ||
++ tail_forever_inotify flushes only after writing, | ||
++ not before reading. */ | ||
++ if (fflush (stdout) != 0) | ||
++ error (EXIT_FAILURE, errno, _("write error")); | ||
++ | ||
+ tail_forever_inotify (wd, F, n_files, sleep_interval); | ||
+ | ||
+ /* The only way the above returns is upon failure. */ | ||
diff -urNad coreutils-7.5~/tests/Makefile.am coreutils-7.5/tests/Makefile.am | ||
--- coreutils-7.5~/tests/Makefile.am 2009-09-11 05:56:07.000000000 -0400 | ||
+++ coreutils-7.5/tests/Makefile.am 2009-09-11 05:56:16.080040689 -0400 | ||
@@ -422,6 +422,7 @@ | ||
rmdir/t-slash \ | ||
tail-2/assert-2 \ | ||
tail-2/big-4gb \ | ||
+ tail-2/flush-initial \ | ||
tail-2/proc-ksyms \ | ||
tail-2/start-middle \ | ||
touch/dangling-symlink \ | ||
diff -urNad coreutils-7.5~/tests/tail-2/flush-initial coreutils-7.5/tests/tail-2/flush-initial | ||
--- coreutils-7.5~/tests/tail-2/flush-initial 1969-12-31 19:00:00.000000000 -0500 | ||
+++ coreutils-7.5/tests/tail-2/flush-initial 2009-09-11 05:56:16.080040689 -0400 | ||
@@ -0,0 +1,41 @@ | ||
+#!/bin/sh | ||
+# inotify-based tail -f didn't flush its initial output before blocking | ||
+ | ||
+# Copyright (C) 2009 Free Software Foundation, Inc. | ||
+ | ||
+# This program is free software: you can redistribute it and/or modify | ||
+# it under the terms of the GNU General Public License as published by | ||
+# the Free Software Foundation, either version 3 of the License, or | ||
+# (at your option) any later version. | ||
+ | ||
+# This program is distributed in the hope that it will be useful, | ||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+# GNU General Public License for more details. | ||
+ | ||
+# You should have received a copy of the GNU General Public License | ||
+# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
+ | ||
+if test "$VERBOSE" = yes; then | ||
+ set -x | ||
+ tail --version | ||
+fi | ||
+ | ||
+. $srcdir/test-lib.sh | ||
+ | ||
+fail=0 | ||
+echo line > in || fail=1 | ||
+stdbuf --output=1K tail -f in > out & | ||
+tail_pid=$! | ||
+ | ||
+# Wait for the backgrounded `tail' to start. | ||
+while :; do | ||
+ env kill -0 $tail_pid && break | ||
+ sleep .1 | ||
+done | ||
+ | ||
+test -s out || fail=1 | ||
+ | ||
+kill $tail_pid | ||
+ | ||
+Exit $fail |
This file contains 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