How should I detect EOF on the stdout from POE::Wheel::Run?
SIGCHLD seems to come well before the last StdoutEvent, buffering
I expect. I also see two ErrorEvents (ARG0='read', ARG1=0). One
soon after the SIGCHLD and another after the last StdoutEvent.
See my test code below.
--
Chris Fedde
The difference between theory and practice is closer in theory than it is
in practice.
--
use POE qw(Filter::Line Wheel::Run);
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('SHUTDOWN', 'shutdown');
$_[KERNEL]->sig('CHLD', 'child');
}
sub error {
print join(' ', 'got an error', @_[ARG0, ARG1, ARG2]), "\n";
}
sub stdin {
print "stdin event\n";
}
sub child {
print "got SIGCHLD\n";
}
sub output {
my ($state, $output) = @_[STATE, ARG0];
print "$state: $output\n";
}
sub shutdown {
$_[HEAP]->{wheel}->kill;
}
POE::Session->create(
inline_states => {
_start => \&_start,
error => \&error,
stdin => \&stdin,
stdout => \&output,
stderr => \&output,
shutdown => \&shutdown,
child => \&child,
}
);
$poe_kernel->run();
exit 0;