From: Eric Blake <ebb9@byu.net>
To: The Vulgar and Unprofessional Cygwin-Talk List <cygwin-talk@cygwin.com>
Subject: Re: My pipe flushes late
Date: Wed, 20 Aug 2008 12:07:00 -0000 [thread overview]
Message-ID: <48AC08D1.20906@byu.net> (raw)
In-Reply-To: <g8h0l5$dv8$1@ger.gmane.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Let's hope your plumbing doesn't overflow. Although the hippos might like
the smell...
According to Robert Schmidt on 8/20/2008 5:54 AM:
> I basically need to pass some output through d2u, then add a prefix to
> each line. Most importantly, I need the line to flush through the pipe
> immediately. However, d2u (or the pipe itself) caches/flushes late.
What you want is to convert d2u's stdout from fully buffered (default, as
per POSIX, for all non-interactive file descriptors) to line-buffered or
unbuffered. On Linux, this can be done with an LD_PRELOAD of a library
that calls setvbuf prior to letting main() run, but I'm not sure cygwin
quite has those hooks. The coreutils list has even seen a proposal for
adding an app just for this purpose, although it is yet to materialize:
http://lists.gnu.org/archive/html/bug-coreutils/2006-03/msg00123.html
At this point, your best bet is to use something that presents d2u with a
pty as stdout (thus output would be line-buffered), rather than a pipe,
then consumes the pty output and throws it over the wall to the original
pipe to sed with flushing. Have you tried expect - according to the link
above, expect provides a script unbuffer that does just what I described?
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkisCNEACgkQ84KuGfSFAYBp5ACdEDjEB+ICCGsA9gkqiBInUkQ5
7R0AnjM5LDtEsQO1s7i3ConCUXkGNaUW
=NZf2
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2008-08-20 12:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 11:55 Robert Schmidt
2008-08-20 12:07 ` Eric Blake [this message]
2008-08-20 13:20 ` Robert Schmidt
2008-08-20 12:16 ` Brian Dessent
2008-08-20 12:40 ` Brian Dessent
2008-08-20 13:15 ` Robert Schmidt
2008-08-20 13:31 ` Brian Dessent
2008-08-20 16:12 ` Christopher Faylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AC08D1.20906@byu.net \
--to=ebb9@byu.net \
--cc=cygwin-talk@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).