A subtle logic bug, probably introduced in r311895, caused tail to print the
first two lines of piped input in forward order, if the very first character
was a newline.
PR: 222671
Reported by: Jim Long <freebsd-bugzilla@umpquanet.com>, pprocacci@gmail.com
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
- Capture exit code in pipeline and test in output.
- Drop awk use in favor of `sleep 2`. This helps guarantee the EPIPE
behavior without the potential race.
In the case where write(2) does not return -1, it does not initialize errno.
This can happen when a broken pipe causes a short write.
I attempted to adapt the submitted test case to ATF but could not figure out
how to make the test run in the ATF environment. So the aborted test is
left disabled, in case someone would like to run it manually or fix it.
PR: 221976
Submitted by: <martin AT lispworks.com> (earlier version)
Sponsored by: Dell EMC Isilon
* Rewrite r_buf to use standard tail queues instead of a hand-rolled
circular linked list. Free dynamic allocations when done.
* Remove an optimization for the case where the file is a multiple of 128KB
in size and there is a scarcity of memory.
* Add ATF tests for "tail -r" and its variants.
Reported by: Valgrind
Reviewed by: ngie
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9067