help-gawk
[Top][All Lists]
Advanced

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

Re: Is GAWK_READ_TIMEOUT supposed to work?


From: Andrew J. Schorr
Subject: Re: Is GAWK_READ_TIMEOUT supposed to work?
Date: Thu, 15 May 2025 11:19:57 -0400

Hi,

There was a bug related to this issue, but it was patched in December,
2023. I think it should be fixed in gawk 5.3.1 and later.  What version
of gawk are you using? If that doesn't explain it, please provide an
example.

Compare:

bash-5.1$ time gawk -ltime 'BEGIN {t0 = gettimeofday(); cmd = "sleep 2"; 
PROCINFO[cmd, "READ_TIMEOUT"] = 1000; cmd | getline x; print gettimeofday()-t0}'
1.0012

real    0m2.005s
user    0m0.002s
sys     0m0.002s

To:

bash-5.1$ time GAWK_READ_TIMEOUT=1000 gawk -ltime 'BEGIN {t0 = gettimeofday(); 
cmd = "sleep 2"; cmd | getline x; print gettimeofday()-t0}'
1.00121

real    0m2.005s
user    0m0.000s
sys     0m0.004s

Regards,
Andy

On Thu, May 15, 2025 at 05:44:02AM -0600, Stan Marsh wrote:
> I have a program (not shown) that uses a co-process.
> I.e., it has: cmd |& getline var
> 
> I want it to timeout if no input has arrived in 3 seconds.  If I do the usual:
> 
>     PROCINFO[cmd,"READ_TIMEOUT"] = 3000
> 
> it works as expected.  But the man page says I can alternatively do:
> 
> $ GAWK_READ_TIMEOUT=3000 gawk 'my program'
> 
> with the same effect.  However this does not work (does not timeout).
> 
> Note: I looked at the source code and found (in io.c) where this variable is
> extracted from the environemnt and parsed.  So, it seems like it should work.
> 
> =================================================================================
> Please do not send me replies to my posts on the list.
> I always read the replies via the web archive, so CC'ing to me is unnecessary.
> 
> Note that they always end up in my Spam file anyway, so it is annoying to 
> have to
> periodically clean that out.



reply via email to

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