From 2a809125299261db9db9b97e93b5885223c6e9d3 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 8 Nov 2016 17:34:44 +0000 Subject: tail: terminate when following pipes and untailable non pipes * src/tail.c (ignore_pipe_or_fifo): Mark the descriptor as -1 for pipes so that any_live_files() detects correctly that the entry is no longer live. * tests/tail-2/pipe-f.sh: Add a test case. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/24903 which was detected using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. --- src/tail.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/tail.c') diff --git a/src/tail.c b/src/tail.c index 718fc8a34..96982ed5b 100644 --- a/src/tail.c +++ b/src/tail.c @@ -2212,7 +2212,10 @@ ignore_fifo_and_pipe (struct File_spec *f, size_t n_files) && (S_ISFIFO (f[i].mode) || (HAVE_FIFO_PIPES != 1 && isapipe (f[i].fd)))); if (is_a_fifo_or_pipe) - f[i].ignore = true; + { + f[i].fd = -1; + f[i].ignore = true; + } else ++n_viable; } -- cgit v1.2.3-54-g00ecf