in reply to IPC::Open3 failure on Win32
I have found some problems in what you posted.
You added something something to the IO::Select before it has been opened. add determines the fileno of $stdout_handl is undefined and returns without adding anything to $stdout.
should bemy $stdout = IO::Select->new(); my $stdout_handle = IO::Handle->new(); $stdout->add($stdout_handle); my $pid = open3( undef, $stdout_handle, undef, $command ); ...error handling...
my $stdout = IO::Select->new(); my $stdout_handle = IO::Handle->new(); my $pid = open3( undef, $stdout_handle, undef, $command ); ...error handling... $stdout->add($stdout_handle);
$stdout_handle->autoflush(1); is useless, since you don't write to $stdout_handle.
I think
This code is intended to merge STDIN and STDOUT and keep them synchronized (no buffering problems).
should read
This code is intended to merge STDOUT and STDERR and keep them synchronized (no buffering problems).
but that's still wrong. Merging them does not avoid buffering problems, as you can see from the following snippet.
>perl -e "print qq{abc\n}; warn qq{def\n};" 2>&1 | perl -pe "s/^/$. /" 1 def 2 abc
Only the child can decide whether it will buffer it's output or not. This cannot be controlled by the parent (unless a particular child provides a configuration option which controls buffering).
And of course, thre's the zombie problem diotalevi already mentioned.
|
|---|