On 21 May 2002 18:44:18 -0400 Peter Chen wrote:
+------------------
| Back in last December, there was a thread on how to handle EOF on the
| stdout from POE::Wheel::Run. Was there any follow up to this?
|
| http:[EMAIL PROTECTED]/msg00767.html
|
| I am seeing the same problem in POE 0.19.
|
| Is there a way to find out that STDOUT has closed?
|
| Pete
+------------------
I have not had time to clean it up yet. But my test code now behaves
predictably: All the output arrives before sigchld. I can't tell
which file handles the errors are on. But all the data has been read
before the sigchld which was the big deal for me.
use POE qw(Filter::Line Wheel::Run);
use Time::HiRes 'time';
use strict;
use warnings;
sub _start {
my $heap = $_[HEAP];
$heap->{wheel} = POE::Wheel::Run->new(
Program => [qw( /usr/bin/find . -type f)],
ErrorEvent => 'error',
StdinEvent => 'stdin',
StdoutEvent => 'stdout',
StderrEvent => 'stderr',
Filter => POE::Filter::Line->new(),
);
$_[KERNEL]->sig('CHLD', 'child');
}
sub output {
print join(':', time(), 'got',
grep({defined} @_[STATE, ARG0, ARG1, ARG2, ARG3, ARG4])), "\n";
}
POE::Session->create(
inline_states => {
_start => \&_start,
error => \&output,
stdin => \&output,
stdout => \&output,
stderr => \&output,
child => \&output,
}
);
$poe_kernel->run();
exit 0;
--
Chris Fedde