GNU bug report logs - #50129
-f - option doesn't respond to single EOF from TTY.

Previous Next

Package: grep;

Reported by: Kaz Kylheku <kaz <at> kylheku.com>

Date: Fri, 20 Aug 2021 01:01:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 50129 <at> debbugs.gnu.org (full text, mbox):

From: Kaz Kylheku <kaz <at> kylheku.com>
To: 50129 <at> debbugs.gnu.org
Subject: Re: bug#50129: closed (Re: bug#50129: -f - option doesn't respond to
 single EOF from TTY.)
Date: Fri, 20 Aug 2021 09:53:38 -0700
Please allow me to add a semi-final comment to a closed bug.

Looking at grep's small body of code for handling the -f
option, I don't see anything substantially different between
3.1 and 3.7. It's the same logic wrapped around the fread
function.

Though the code has been worked on, there is no difference
in how the end of input is detected.

From that perspective, this looks like it may in fact be a
problem in the libc fread function. However, on the
same system, I cannot reproduce the issue with a similar
loop around fread, e.g. with this program:

  #include <stdio.h>

  int main(void)
  {
    char buf[128];
    setvbuf(stdin, NULL, _IOFBF, 0);
    while (fread(buf, sizeof buf, 1, stdin) != 0);
    return 0;
  }

Regardless of buffering mode, the fread loop promptly
quits if Ctrl-D is given from the TTY on an empty line.

The most plausible explanation at this point is that Debian/Ubuntu
had applied some stinky patch to grep.

If I have some time, I will drill into that, in which case
I will post a final comment here, too.

Cheers ...




This bug report was last modified 3 years and 275 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.