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: arnold
Subject: Re: How to get gawk to timeout when reading a file.
Date: Fri, 10 Mar 2023 01:38:57 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Andy is correct here.  With these changes, gawk indeed
exits.

Thanks,

Arnold

"Andrew J. Schorr" <aschorr@telemetry-investments.com> wrote:

> 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]