Module Name:    src
Committed By:   christos
Date:           Tue Dec 28 19:22:58 UTC 2021

Modified Files:
        src/external/gpl2/grep/dist/src: grep.c

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl2/grep/dist/src/grep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl2/grep/dist/src/grep.c
diff -u src/external/gpl2/grep/dist/src/grep.c:1.3 src/external/gpl2/grep/dist/src/grep.c:1.4
--- src/external/gpl2/grep/dist/src/grep.c:1.3	Tue Dec 28 09:59:02 2021
+++ src/external/gpl2/grep/dist/src/grep.c	Tue Dec 28 14:22:58 2021
@@ -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
     }
   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;

Reply via email to