in reply to Re^3: Win32::Process handle inheritance (don't use 'local' on file handles)
in thread Win32::Process handle inheritance
The real problem here is [...] Nothing you do to the current process Perl handles or CRT handles will have any influence upon the created process at all.
Actually, no, it just works:
X:\> type stdout.pl #!/usr/bin/perl -w use strict; require Win32::Process; open STDOUT, "> stdout.txt" or die "Can't write stdout.txt: $!\n"; my $proc; Win32::Process::Create( $proc, $ENV{COMSPEC}, "/c dir", 1, 0, "." ) or die "Can't run 'dir': $^E\n"; X:\> perl stdout.pl X:\> type stdout.txt Volume in drive X is NSA_SECRETS Volume Serial Number is 007A-DEAD Directory of X:\ 2008-05-13 07:29 246 stdout.pl 2008-05-13 07:29 0 stdout.txt 2 File(s) 246 bytes X:\>
(output trimmed to protect national secrets.)
To save/restore the parent's original STDOUT, just follow the examples briefly described by ysth that are more fully covered in that standard open documentation.
- tye
|
|---|