bug-gawk
[Top][All Lists]
Advanced

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

Re: How to get gawk to timeout when reading a file.


From: Andrew J. Schorr
Subject: Re: How to get gawk to timeout when reading a file.
Date: Thu, 9 Mar 2023 18:15:50 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

> #!/usr/bin/gawk -f 
> 
> BEGIN{
>     # Polling read...
>     PROCINFO[Service, "READ_TIMEOUT"] = 1000;

What's the value of the Service variable here?
It should be set to "../fifo", I hope.

>     PROCINFO["input", "RETRY"] = 1; 

Shouldn't this be:
     PROCINFO["../fifo", "RETRY"] = 1; 
?

> 
>     system("sleep 1s; echo Run process using system.");
> 
>     do
>     {
>         ret = getline < "../fifo";
>         # Quickly eat the rest of the input which could
>         # not be read due to the other process running.
>     }
>     while(ret == 1);
> }
> 
> As you can see, I'm reading from a FIFO. The process on the other end
> sends data once per second. It is:
> sudo /usr/sbin/iftop -tB | stdbuf -oL grep 'Total receive rate:' > fifo
> 
> If you can get the code sample to work correctly, then the program will
> exit while the process feeding the fifo is still running.

Have you tried running strace on the gawk script to see in which call
it's blocking?

Regards,
Andy



reply via email to

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