Web lists-archives.com

Re: grep < fifo fails




On Mon, 08 Oct 2018 10:24:01, 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
...

> 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.
[snip]

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

Right.

64-@@ echo aaa > fifo & grep . < fifo
[1] 3956
aaa
[2]+  Done                    echo aaa > fifo

The following rough patch to the Cygwin executive ... uhm, Cygwin DLL,
makes the above work.

winsup/cygwin/fhandler.h:

class fhandler_fifo: public fhandler_base_overlapped
{
...
// Henri
  off_t lseek (off_t, int)
  {
    set_errno (ESPIPE);
    return -1;
  }
...
};

(I cheated; I did a copy/paste of what is already present in fhandler.h)

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