* tail: fix race condition (fix#3765)
There exists a race condition (RC) that can occur if changes to a path
happen after the initial print loop in `uu_tail()`, but before the
path is added to the notify-Watcher thread in `follow()`.
To minimize the window where the RC can occur, this moves starting the
Watcher thread and adding paths to it from `follow()` to the initial
print loop in `uu_tail()`.
Additionally, to make sure the RC cannot happen in
"gnu/tests/tail-2/F-headers.sh", the error message that is used as a trigger
in this test, is delayed until the path is added to the Watcher thread.
* build-gnu: remove workarounds for tail
Remove workarounds for "tests/tail-2/F-headers.sh" which are
(presumably) no longer needed because of the race condition fix.
* build-gnu: remove workarounds for tail
Remove workarounds for "tests/tail-2/F-headers.sh" which are
(presumably) no longer needed because of the race condition fix.
* tail: refactor to minimize chances of RC
Move "adding paths to Watcher thread" to its own loop and run this loop
before the initial tail-print-loop in order to minimize the window for
race conditions.
* tail: reduce CPU load for polling
This reduces the CPU load for polling drastically (from ~80% down to ~5%)
by removing/fixing several previous workarounds related to polling,
while still passing all related GNU test-suite checks.
* set Notify::PollWatcher delay to: sleep_sec/10 instead of
sleep_sec/100
* set recv_timeout to sleep_sec instead of sleep_sec/100
* remove the manual polling of watched files
Bugs:
* fix an issue with headers to consistently pass
"test_follow_name_retry_headers" and "gnu/tests/tail-2/overlay-headers.sh"
Code clean-up and refactor
* make fields of struct FileHandling private (and add getters/setters)
to ensure that the paths are absolute and match the paths returned by
Notify::Events
* replace calls to "crash!" with "return USimpleError"
* clean-up formatting
At least, two use cases:
* when hacking on test update
* when we want to rebuild only Rust coreutils with the right option
Indeed, the GNU code should not cache often in this case
Remove the substitution of uutils `timeout` with GNU `timeout` before
running the GNU test suite. Some of these replacements were not
actually operational because the regex was not appropriate (for
example, the test file had `timeout 10` but the regex would only match
`timeout [0-9]`). Others no longer need to be used because the uutils
version of `timeout` works well enough now to terminate a process
within the given period of time.
- add more logging for better fault tracking
- generalize for use in either RELEASE or DEBUG build mode (default to 'release')
- improve variable naming precision/specificity
Add the `g` flag to one of the regular expression substitutions in
`util/build-gnu.sh` so that all instances of `printf` are replaced
with `/usr/bin/printf` in `tests/dd/ascii.sh` instead of just one
instance per line.