GNU bug report logs -
#22278
[PATCH] grep: report line-buffered write error right away
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Thu, 31 Dec 2015 07:39:02 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
* src/grep.c (prline): When line buffered, if there is a write
error, report it immediately rather than waiting until the next
line of output.
---
src/grep.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/grep.c b/src/grep.c
index 06f315d..696f4ce 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1180,6 +1180,9 @@ prline (char *beg, char *lim, char sep)
if (!only_matching && lim > beg)
fwrite (beg, 1, lim - beg, stdout);
+ if (line_buffered)
+ fflush (stdout);
+
if (ferror (stdout))
{
write_error_seen = true;
@@ -1187,9 +1190,6 @@ prline (char *beg, char *lim, char sep)
}
lastout = lim;
-
- if (line_buffered)
- fflush (stdout);
}
/* Print pending lines of trailing context prior to LIM. Trailing context ends
--
2.5.0
This bug report was last modified 9 years and 148 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.