bug-gawk
[Top][All Lists]
Advanced

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

Re: gawk -i inplace is an order of magnitude faster when also redirectin


From: arnold
Subject: Re: gawk -i inplace is an order of magnitude faster when also redirecting stdout
Date: Sun, 03 Mar 2024 11:49:51 -0700
User-agent: Heirloom mailx 12.5 7/5/10

arnold@skeeve.com wrote:

> Adding a setvbuf() call didn't work.
>
> Using freopen() instead of playing games with the file descriptor
> might work, but it's also a hassle.
>
> Andy - can you look at this? Try: in inplace_begin
> - dup stdout to a new fd and save it as now
> - do freopen on stdout to the file. this should set block buffering
>
> In inplace_end, do freopen of /dev/fd/NNN where NNN is the duped
> fd from the original stdout.
>
> Thanks,
>
> Arnold

I spent a bunch of time on this and could not make anything
work. So I'm going with a documentation patch.

Arnold
----------------------
diff --git a/doc/gawk.texi b/doc/gawk.texi
index a093cb08..769c82c5 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -39495,6 +39495,11 @@ For each regular file that is processed, the extension 
redirects
 standard output to a temporary file configured to have the same owner
 and permissions as the original.  After the file has been processed,
 the extension restores standard output to its original destination.
+(Due to this implementation, it helps to redirect @command{gawk}'s
+standard output to @file{/dev/null}, instead of leaving it set to
+your terminal, so that output will be block-buffered instead of
+line-buffered.)
+
 If @code{inplace::suffix} is not an empty string, the original file is
 linked to a backup @value{FN} created by appending that suffix.  Finally,
 the temporary file is renamed to the original @value{FN}.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]