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 ...



Reply via email to