Open with non-blocking I/O and then reset the flags to avoid blocking for
FIFOs. This is a lot easier to do than adding another stat(2) to avoid open(2).
This commit is contained in:
parent
0332878aff
commit
6e96237455
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: grep.c,v 1.3 2021/12/28 14:59:02 christos Exp $ */
|
||||
/* $NetBSD: grep.c,v 1.4 2021/12/28 19:22:58 christos Exp $ */
|
||||
|
||||
/* grep.c - main driver file for grep.
|
||||
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
|
||||
|
@ -911,9 +911,12 @@ grepfile (char const *file, struct stats *stats)
|
|||
}
|
||||
else
|
||||
{
|
||||
while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
|
||||
while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0 && errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (desc >= 0 && (status = fcntl (desc, F_GETFL, 0)) != -1)
|
||||
fcntl (desc, F_SETFL, status & ~O_NONBLOCK);
|
||||
|
||||
if (desc < 0)
|
||||
{
|
||||
int e = errno;
|
||||
|
|
Loading…
Reference in New Issue