Re: Help: How to process output of a program

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Quoted text here. Click to load it

Based on my test, I'd say it doesn't work on Win32, or at least not

use strict;
use warnings;
use IPC::Open2;
warn open2 my $in, my $out, q;
print $out qq foreach (1..100);
close $out or die;
print while (<$in>);

This works on Linux, but hangs on Windows.  It hangs at the while (<$in>).
Since sort needs to read all input before generating any output,
deadlock should not be an issue.  It also leaves sort.exe hanging around.

(I actually starting using "cat"/"type", using the >& to redirect to
another filehandle to avoid deadlocks, but I couldn't figure out how to
make Window's "type" read from its stdin.  So I switched to sort.  Then
once using sort, I realized I no longer needed >& so simplified it.  None
of these steps worked on windows).

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)

Copyright 1987-2006, Larry Wall

Binary build 817 [257965] provided by ActiveState Built Mar 20 2006 17:54:25


-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: Help: How to process output of a program wrote:

Quoted text here. Click to load it

Interesting.  I've honestly not tried this on Win32.  I've been
privileged enough to _not_ have to use Windows for many, many years.
Maybe I'll install ActiveState's Perl on a Windows laptop and run some
tests (but I probably won't).  I appreciate the follow up.
Tim Greer, CEO/Founder/CTO,, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Re: Help: How to process output of a program

On 15 Oct 2008 18:06:31 GMT, wrote:

Quoted text here. Click to load it


for  good examples of how to setup non-blocking pipe reads on win32


Site Timeline