Repository navigation
tail: stop at the original end when output is appended to the input - #15066
Conversation
|
GNU testsuite comparison: |
|
Closing this PR as #15063 already fixed the same issue. Anyway, thanks for your PR! |
|
@cboos please convert to draft |
549584e to
14cc64d
Compare
|
The macOS fix is available, but I'll wait until the end of the current CI cycle before pushing it.
|
Merging this PR will regress 2 benchmarks
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
Well, I don't see how that PR affects uu_factor performance, but otherwise I think I did my best to get a green build! The macOS failure seems to be a known intermittent one (#14888). One more nit: I wasn't sure about the A version without |
799d2da to
8a16c77
Compare
|
|
| /// when tail behaves: a coverage build writes its profile data on exit, past | ||
| /// any small cap. | ||
| #[cfg(unix)] | ||
| struct SigxfszGuard(libc::sighandler_t); |
There was a problem hiding this comment.
Since #15131, we have ignore_sigxfsz on UCommand, can you use that?
8a16c77 to
2f6705d
Compare
|
On second thought, I realized there were no tests for Windows yet... |
2f6705d to
265674f
Compare
265674f to
220ad89
Compare
|
(Claude) Rebased onto current main. Main had meanwhile moved The last commit (220ad89) fixes one more corner case of the same issue: with a header ( |
|
The branch update was needed because Vancouver/America switched time zones to MST today; the failing test test_date_tz_with_relative_time was fixed by 7c9d4e7. |
|
Please update the branch history as follows:
|
76224c7 to
187f0fa
Compare
|
Hello @xtqqczze, Is there anything I can do about this failing job? Manpage Validation / Validate manpages with mandoc (fr_FR.UTF-8) (pull_request). It's been retried 3 times already (not by me). Would one more rebase help? More radically: do you think it was the wrong approach to try to make this tail-on-itself work in some sensible way? Maybe a simpler approach would have been to just bail out. The code will certainly be simpler that way, and there's precedent ( |
| // Restore in a single write. On Windows, copying sets the final size | ||
| // before writing the data, so tail could read zeros there and then wait | ||
| // for more data after them. | ||
| at.write(source, &at.read(backup)); |
There was a problem hiding this comment.
unrelated to this fix, could you please move it into a separate pr?
There was a problem hiding this comment.
Done. See #16316 for the separate mini-PR.
* tests/tail/append-to-input.sh: New test. * tests/local.mk (all_tests): Reference it. uutils/coreutils#15066 Link: #455
With `tail f >> f`, tail read on to the end of file while its own output kept moving that end, so for files above one block it copied itself until the filesystem was full. Smaller files read part of their own output back. When standard output is the file being read, recognised by device and inode as cat does, copy the file only up to the size it had when tail opened it, on both the seeking and the streaming path. Counting from the end also starts at that size, since a header (`tail -v`) may already have been appended beyond it. A file that another process appends to is still read to its end, as before. The tests append tail's output to its own input and stop tail once the file grows past 1 MiB: with a file size cap on unix, where SIGXFSZ is ignored so that a coverage build can still write its profile data, and by watching the size of the file on Windows. Fixes uutils#15057
On macOS and Windows, standard input is not resolved to a path, so `tail < f >> f` does not go through tail_file and its bound: it is read like a pipe, until the end of a file that our own output keeps moving. Apply the same bound there, from the descriptor itself on unix and from a duplicate of the handle on Windows, which shares its file position. Its size is taken before the header is printed, which would otherwise be copied back once.
187f0fa to
468a474
Compare
|
Thanks for your PR |
When
tail's output is appended to the file it reads (tail -n1 f >> f),tailreads up to the end of file, but its own output keeps moving that end. On a file larger than one block it copies itself until the filesystem is full. On a smaller file it reads part of its own output back (tail -n+2 g >> gona\nb\nc\nappendsb\nc\nb\nc\n).This change makes
tailcopy a regular file only up to the size it had whentailopened it, in every mode and on both the seeking and the streaming path. A reported size of 0 is treated as unknown, since files in/procreport 0 whatever they contain. Follow mode is unaffected: it continues from that point.The regression test appends
tail's output to its own input under anRLIMIT_FSIZEcap, so if the fix regresses the test fails instead of filling the disk.This is an alternative to #15063, which bounds only
-n N(counted from the end) on files larger than one block. In the modes that count from the start of the file, GNU also runs away, and this patch stops there as well. That makes it stricter than GNU in those modes; the comparison table is in the issue.Closes #15057
🤖 Generated with Claude Code