Web lists-archives.com

Re: grep < fifo fails




On Fri, 05 Oct 2018 17:32:16, Houder wrote:
> On Thu, 04 Oct 2018 18:02:03, Houder wrote:
> > On Wed, 03 Oct 2018 20:46:11, Houder wrote:
> > > On Wed, 3 Oct 2018 15:37:14, Ole Tange wrote:
> > > > This works:
> > > > 
> > > > $ mkfifo fifo
> > > > $ echo > fifo & grep .  fifo
> > > > [1] 10232
> > > > [1]+  Done                    echo > fifo
> > > > 
> > > > But this fails:
> > > > 
> > > > $ echo > fifo & grep . < fifo
> > > > [1] 11756
> > > > grep: (standard input): Invalid argument
> > > > [1]+  Done                    echo > fifo
> > > > 
> > > > I see the same behavior on MINGW, but I do not see the same behavior on GNU=
> > > > /Linux.
> > 
> > My apologies. Did not read your post as careful as I should have the first time.
> > You are correct: grep is in error here.
> 
> Filed this bug at bug-grep@xxxxxxx; it is filed under number 32943.
> 
>  - https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32943
> 

grep fails on Cygwin because lseek() on Cygwin fails to recognize
that it is applied to a FIFO. As result of that, it returns EINVAL
in errno, where it should return ESPIPE.

Receiving the wrong value in errno forces reset() (in src/grep.c)
to return false, upon which grep fails.

Before v2.27 of grep, a call to S_ISREG(st->st_mode) in reset()
prevented the call of lseek() and made reset() return true.

The call to S_ISREG() has been removed in v2.27 of grep.

The solution would be either to correct Cygwin's executive or to
insert a Cygwin-specific kludge in grep (in reset() ).

Regards,
Henri


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple