| www.delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Message-ID: | <416D1B95.8050901@x-ray.at> |
| Date: | Wed, 13 Oct 2004 14:12:05 +0200 |
| From: | Reini Urban <rurban AT x-ray DOT at> |
| User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.8a3) Gecko/20040817 |
| MIME-Version: | 1.0 |
| To: | Nuno Leitao <nuno DOT leitao AT integralis DOT com> |
| CC: | "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com> |
| Subject: | Re: Buffered output/Forked processes |
| References: | <8904DDEEB811D6118AF900508BB832FA080995E0 AT the-exch-c DOT ai DOT pri> |
| In-Reply-To: | <8904DDEEB811D6118AF900508BB832FA080995E0@the-exch-c.ai.pri> |
| X-IsSubscribed: | yes |
Nuno Leitao schrieb:
> I have a Perl script which looks like:
>
> open( VMSTAT, "vmstat 5|" );
> VMSTAT->autoflush( 1 );
> while( <VMSTAT>) {
> print $_;
> }
>
> Now, under Linux and other UNIX OS's this works fine, and "print $_" will
> print the vmstat output every 5 seconds since the output from vmstat is not
> buffered. Under Cygwin however, it seems vmstat will always buffer its
> stdout with the undesirable effect that lines come in batches as the output
> buffer gets full and is flushed by the Cygwin C libraries.
>
> Is there a way to go around this without having to patch and recompile
> vmstat or other binaries I might want to use in this way ?
basic perl question, not cygwin related.
$ perldoc -q buffer
$ perldoc -f select
cygwin perl doesn't honor $| ? not true.
Because you told VMSTAT not to buffer.
But you shold have told it to STDOUT.
open( VMSTAT, "vmstat 5|" );
VMSTAT->autoflush( 1 );
$| = 1; # STDOUT is selected so STDOUT will get unbuffered.
while( <VMSTAT>) {
print $_;
}
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |