[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-grep] [patch] getting '--devices=skip' to work

From: Jim Meyering
Subject: Re: [bug-grep] [patch] getting '--devices=skip' to work
Date: Thu, 18 Nov 2004 13:39:10 +0100

Benno Schulenberg <address@hidden> wrote:
> When running grep with --devices=skip it nevertheless hangs when
> coming across a fifo.  It appears to hang on line 898 of grep.c:
>     while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
>       continue;
> The checks on the file type and the skipping statements come too
> late.  The attached patch moves those lines and adds a check on
> fifos.  It works for me, grep now skips all devices and fifos when
> '-D skip' is given.  Some of the lines that come after the patch
> are made superfluous, but I haven't bothered with those.

Another way to keep open from blocking on fifos is
to use the O_NONBLOCK flag:

     while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0
             && errno == EINTR)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]