Subject: bug#25041: Bugs in TAC and TAIL for closed stdin

From: Pádraig Brady <[email-masked]>
Date: Sun, 27 Nov 2016 21:22:48 +0000

On 27/11/16 15:51, Jim Meyering wrote:
> On Sun, Nov 27, 2016 at 7:40 AM, Pádraig Brady <[email-masked]> wrote:
>> I'll push the attached later
> 
> Thanks to both of you.
> 
> That patch looks fine, modulo a formatting nit: the second line is
> indented one space too far:
> 
> +              f->ignore = ! (reopen_inaccessible_files
> +                              && follow_mode == Follow_name);
> 

Done.
Also we should probably clear any errors such as ENOSPC
from the stream before reuse for the next input:

diff --git a/src/tac.c b/src/tac.c
index 2e820fa..c1b6003 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -477,6 +477,7 @@ temp_stream (FILE **fp, char **file_name)
     }
   else
     {
+      clearerr (tmp_fp);
       if (fseeko (tmp_fp, 0, SEEK_SET) < 0
           || ftruncate (fileno (tmp_fp), 0) < 0)
         {

cheers,
Pádraig