It seems that ActiveState has more problems with pipes than it does with fork.
If it supports redirects reasonably well, this avoids pipes entirely and
may be more stable as a result (but possibly slower):
# IO::File is standard in Perl 5.x, new_tmpfile
# returns an open filehandle to an already unlinked file
use IO::File;
my $out = IO::File->new_tmpfile;
file
my $pid = fork;
defined $pid or die $!;
if (!$pid) {
# redirects STDOUT to $out file
open STDOUT, '>&', $out or die $!;
exec('foo','bar');
}
waitpid $pid, 0;
seek $out, 0, 0;
while (<$out>) {
...
}
Writing and reading from a tempfile are very fast for me in Linux, and probably
not much slower than pipes. Of course I'm still assuming file descriptors stay
shared after a 'fork', which may be asking too much on Windows. Using something
from File::Temp to get a temp filename would still work.
--
Eric Wong
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html