Source-Changes-HG archive

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

[src/trunk]: src/external/gpl2/grep/dist/src Open with non-blocking I/O and t...



details:   https://anonhg.NetBSD.org/src/rev/02642e4ab5e8
branches:  trunk
changeset: 1029263:02642e4ab5e8
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Dec 28 19:22:58 2021 +0000

description:
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).

diffstat:

 external/gpl2/grep/dist/src/grep.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 0137ca200850 -r 02642e4ab5e8 external/gpl2/grep/dist/src/grep.c
--- a/external/gpl2/grep/dist/src/grep.c        Tue Dec 28 19:13:40 2021 +0000
+++ b/external/gpl2/grep/dist/src/grep.c        Tue Dec 28 19:22:58 2021 +0000
@@ -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 @@
     }
   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;



Home | Main Index | Thread Index | Old Index