perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Hay <steve....@uk.radan.com>
Subject Re: t/SMOKE on win32
Date Tue, 07 Oct 2003 09:06:43 GMT
Barrie Slaymaker wrote:

> On Oct 6 2003, Steve Hay wrote:
>
>> Randy Kobes wrote:
>> test1.pl passes a scalar to run3
>> test2.pl redirects STDOUT to a scalar and has run3 inherit it
>
>
> Does
>
>    open STDOUT, '>', \$logout;
>
> create a real filehandle at the OS level, or does it use I/O layers
> to redirect the perl script's output to a scalar?  If it's not a real
> filehandle, system(), and thus IPC::Run3::run3(), can't pass it down
> to the child. 

I suspect it's not a real OS filehandle - if I run a Perl script that 
opens a file and then goes to sleep then when I look at the perl.exe 
process in Process Explorer (from www.sysinternals.com) I can see the 
filehandle that it is using.  By contrast, if the Perl script "opens" a 
scalar as above then Process Explorer doesn't show any new OS handle.  
So that probably explains why test2 doesn't work.

>
>
>> test3.pl redirects STDOUT to a scalar and passes that scalar to run3
>
>
> This works on linux, will test on Win32, rewriting the crucial line
> to:
>
>    run3 [ $^X, "-leprint'hi'"], undef, \$logout, undef; 

I've tried that, i.e. the test3 script is now:

=====
use strict;
use warnings;

use IPC::Run3;

my $savout;
open $savout, '>&STDOUT' or die "Can't dup STDOUT: $!\n";
close STDOUT or die "Can't close original STDOUT: $!\n";
my $logout = '';
open STDOUT, '>', \$logout or die "Can't redirect STDOUT: $!\n"

run3 [$^X, "-leprint'hi'"], undef, \$logout, undef;

close STDOUT or die "Can't close redirected STDOUT: $!\n";
open STDOUT, '>&', $savout or die "Can't restore STDOUT: $!\n";
close $savout or die "Can't close saved STDOUT: $!\n";

print "Captured '$logout' from STDOUT\n";
print "Done\n";
=====

but it still doesn't work on my WinXP machine.

- Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message