The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7a7f74dbcc4f41d98218471297eaa629e34326e2
commit 7a7f74dbcc4f41d98218471297eaa629e34326e2 Author: Kyle Evans <kev...@freebsd.org> AuthorDate: 2025-08-08 04:52:53 +0000 Commit: Kyle Evans <kev...@freebsd.org> CommitDate: 2025-08-08 05:05:10 +0000 grep: toss in some explicit fflush() grep|tee of the src/ tree for infrequently-occurring strings is fairly annoying; drop some tactical flushes at line-match boundaries to reduce the long stalls. In the case of `grep -o`, we'll flush after multiple lines if there are multiple matches within a single line of text, while for non`-o` we'll flush generally after every line. --- usr.bin/grep/util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index ed87e56956f6..5b40405852b3 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -728,6 +728,8 @@ void grep_printline(struct str *line, int sep) { printline_metadata(line, sep); fwrite(line->dat, line->len, 1, stdout); putchar(fileeol); + + fflush(stdout); } static void @@ -834,6 +836,7 @@ printline(struct parsec *pc, int sep, size_t *last_out) *last_out = pc->ln.len; } putchar('\n'); + fflush(stdout); } else if (!oflag) { /* * -o is terminated on every match output, so this @@ -843,6 +846,8 @@ printline(struct parsec *pc, int sep, size_t *last_out) * to terminate if it needs to. */ terminated = false; + } else { + fflush(stdout); } } else grep_printline(&pc->ln, sep);