From: Pádraig Brady Date: Wed, 7 Jun 2017 07:17:57 +0000 (-0700) Subject: tail: with --pid, ensure all inotify events are processed X-Git-Tag: v8.28~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba16bdd89064a58d828d557827a473fc02b0d5ad;p=thirdparty%2Fcoreutils.git tail: with --pid, ensure all inotify events are processed * NEWS: Mention the bug fix. * src/tail.c (tail_forever_inotify): With --pid, avoid waiting for new events if there are still events to process. * tests/tail-2/inotify-dir-recreate.sh: Adjust to trigger. --- diff --git a/NEWS b/NEWS index c811dbcb50..508c08f6bc 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,11 @@ GNU coreutils NEWS -*- outline -*- tail -F 'dir/file' is now monitored even when 'dir' is replaced. [bug introduced with inotify support added in coreutils-7.5] + tail -f with --pid=PID will now process all inotify events. + Previously events may have been ignored completely upon PID death, + or ignored until future events on the monitored files. + [bug introduced with inotify support added in coreutils-7.5] + uptime no longer outputs the AM/PM component of the current time, as that's inconsistent with the 24 hour time format used. [bug introduced in coreutils-7.0] diff --git a/src/tail.c b/src/tail.c index 6328fe0ef8..3582321bce 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1577,7 +1577,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, /* When watching a PID, ensure that a read from WD will not block indefinitely. */ - if (pid) + if (pid && (len <= evbuf_off)) { if (writer_is_dead) exit (EXIT_SUCCESS); diff --git a/tests/tail-2/inotify-dir-recreate.sh b/tests/tail-2/inotify-dir-recreate.sh index 02ddf96a4b..5c74c1dfa7 100755 --- a/tests/tail-2/inotify-dir-recreate.sh +++ b/tests/tail-2/inotify-dir-recreate.sh @@ -54,7 +54,7 @@ grep_timeout_ () mkdir dir && echo 'inotify' > dir/file || framework_failure_ #tail must print content of the file to stdout, verify -timeout 60 tail -F dir/file >out 2>&1 & pid=$! +timeout 60 tail --pid=$$ -F dir/file >out 2>&1 & pid=$! grep_timeout_ 'inotify' 'out' || { cleanup_fail_ 'file to be tailed does not exist'; }