From 659060233ff2cff324be5cf4cc40b782068d45fd Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Wed, 9 Nov 2016 17:51:13 +0000 Subject: tail: ensure -f --retry 'missing' handles truncation * src/tail.c (tail_forever): The BLOCKING optimization is only enabled for non regular files (which can't be truncated), so ensure we don't enable that unless we've a valid file descriptor. * tests/tail-2/retry.sh: Add a test case. * NEWS: Mention the bug fix. --- src/tail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tail.c b/src/tail.c index b3018d526..66aad5b78 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1111,7 +1111,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) { /* Use blocking I/O as an optimization, when it's easy. */ bool blocking = (pid == 0 && follow_mode == Follow_descriptor - && n_files == 1 && ! S_ISREG (f[0].mode)); + && n_files == 1 && f[0].fd != -1 && ! S_ISREG (f[0].mode)); size_t last; bool writer_is_dead = false; -- cgit v1.2.3-54-g00ecf