bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Coprocessing deadlocks?


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Coprocessing deadlocks?
Date: Thu, 4 Jan 2018 08:21:20 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Panos,

On Thu, Jan 04, 2018 at 08:00:35AM +0200, Panos Papadopoulos wrote:
> I'm sure that you're aware of this topic in comp.lang.awk:
> https://groups.google.com/forum/#!topic/comp.lang.awk/pz4gmSw0uas
> 
> If you're not, here is a simple script that seems to be malfunctioning:
> 
> BEGIN {
> > cmd = "tr a-z A-Z"
> > print "abc" |& cmd
> > cmd |& getline
> > print
> > }
> 
> 
> The above must print ABC, but seems to freeze (gawk version 4.2).

Actually, it should freeze, because the stdout from "tr" is
buffered. You need to use 'stdbuf' or the pty feature to fix
the stdio buffering issue. If you add:
      PROCINFO[cmd, "pty"] = 1
then you find the actual bug that Arnold is working on (the 
output is "abc" instead of "ABC").

> If you change cmd to "cat" works fine.

It seems that "cat" disables buffering by default, so does not
exhibit the deadlocking issue.

Regards,
Andy



reply via email to

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