[Top][All Lists]

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

Re: [bug-gawk] Problem with printing 5000 lines to a coprocess

From: Andrew J. Schorr
Subject: Re: [bug-gawk] Problem with printing 5000 lines to a coprocess
Date: Wed, 24 Dec 2014 14:08:50 -0500
User-agent: Mutt/1.5.23 (2014-03-12)


On Wed, Dec 24, 2014 at 07:58:21PM +0200, Aharon Robbins wrote:
> If I understand how things work, using ptys solves the problem because
> the tty driver always returns data to the read system call after one line
> has been seen (the newline character). So the program at the other end
> can try to read as much as it wants, but it only gets one line at a time.
> The main caveat is that the pty won't pass all binary data; some control
> characters have an influence on how it behaves (such as ^D for EOF).
> I will try to add something to manual, but am not sure when I'll get to it.

There were 2 issues.  One is the need to use ptys (or a wrapper program like
"stdbuf") to achieve line-buffering of coprocess output.  I think that is
already well-documented in the manual, although we may want to mention that
stdbuf can be used on Linux systems and gives better performance than ptys.
I'm not sure how many platforms have this utility.

The second issue is a deadlock that can occur when you try to write a ton of
data to a coprocess before reading back any results (the deadlock occurs
because the coprocess blocks on write, and then gawk blocks on write as well).


reply via email to

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