From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7581 invoked by alias); 20 Aug 2008 12:07:41 -0000 Received: (qmail 7457 invoked by uid 22791); 20 Aug 2008 12:07:40 -0000 X-Spam-Check-By: sourceware.org Received: from qmta09.emeryville.ca.mail.comcast.net (HELO QMTA09.emeryville.ca.mail.comcast.net) (76.96.30.96) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 20 Aug 2008 12:06:41 +0000 Received: from OMTA02.emeryville.ca.mail.comcast.net ([76.96.30.19]) by QMTA09.emeryville.ca.mail.comcast.net with comcast id 4ars1a0060QkzPwA9c6fnh; Wed, 20 Aug 2008 12:06:39 +0000 Received: from [192.168.0.101] ([67.166.125.73]) by OMTA02.emeryville.ca.mail.comcast.net with comcast id 4c6e1a0021b8C2B8Nc6eiw; Wed, 20 Aug 2008 12:06:39 +0000 X-Authority-Analysis: v=1.0 c=1 a=mDV3o1hIAAAA:8 a=xe8BsctaAAAA:8 a=DxdgaWzwFVZhnxBvGzkA:9 a=GYOCwsghqX5itYekzQeQ3h8qcPYA:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10 Message-ID: <48AC08D1.20906@byu.net> Date: Wed, 20 Aug 2008 12:07:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080708 Thunderbird/2.0.0.16 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: The Vulgar and Unprofessional Cygwin-Talk List Subject: Re: My pipe flushes late References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-talk-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-talk-owner@cygwin.com Reply-To: The Vulgar and Unprofessional Cygwin-Talk List X-SW-Source: 2008-q3/txt/msg00050.txt.bz2 -----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-----