GNU bug report logs -
#32943
grep pattern < fifo fails on Cygwin (and MinGW), but not on Linux
Previous Next
Reported by: Houder <houder <at> xs4all.nl>
Date: Fri, 5 Oct 2018 10:15:01 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 32943 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2018-10-06 22:12, Paul Eggert wrote:
[snip}
> My guess is that you've got an old version of grep on Cygwin, and need
> to upgrade to the current version. If you still have problems with the
> latest version, please investigate via GDB and/or other means exactly
> why grep is failing for you ...
Hi Paul,
I have found what causes grep to fail. (after building v3.1 of grep)
But in order not to mislead others reading this thread, I must correct
what I
wrote in my initial post. There I wrote: "as far as I can tell, the code
that
is executed on Cygwin is not the same as the one that is executed on
Linux".
Wrong. My "strace-ing" misled me.
Returning to grep's failure on Gygwin:
grep terminates with an error on Cygwin because lseek() on Cygwin fails
to
ascertain that it is applied to a FIFO.
As result Cygwin's executive returns EINVAL in errno, in stead of
ESPIPE, as
required (my interpretation after reading "man 2 lseek").
ESPIPE is expected in reset() (src/grep.c), after lseek() has been
applied to
stdin (which points to a FIFO here).
Until v2.26 of grep, a call to S_ISREG(st->st_mode) circumvented the
call to
lseek() (and the call to suppressible_error()) and made reset() return
true.
Version v2.27 of grep removed the call to S_ISREG(st->st_mode). As
result of
that lseek() is invoked.
lseek() fails, but an exception is made for errno == ESPIPE. For this
reason
grep does not fail on Linux (reset() returns true).
However on Cygwin, suppressible_error() is called and reset() returns
false,
which makes grep fail on Cygwin.
You can see for yourself in the attached logfiles (GDB sessions).
-----
To what did I apply GDB?
- downloaded the tarball (grep-3.1.tar.xz) from
http://ftp.gnu.org/gnu/grep/
- build grep using "make CFLAG='-O -g3'", both on Linux and Cygwin
Regards,
Henri
[gdb-cygwin.log (text/plain, attachment)]
[gdb-linux.log (text/plain, attachment)]
This bug report was last modified 5 years and 135 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.