Subject: | POE::Wheel::Run doesn't deliver closeevent when Conduit is set to 'pty' or 'pty-pipe' |
see attached script. when line 29 (Conduit) is commented out, one gets
the following:
$ ./run.pl
wheel 1 started (pid 498)
stdout: bin
[...]
stdout: var
wheel 1 stopped
pid reaped: 498
but when line 29 is in use (ie, Conduit is set to pty), one gets the
following:
$ ./run.pl
wheel 1 started (pid 496)
stdout: bin [...] var
pid reaped: 496
==> no closeevent for the wheel!
the ls output changes (n lines / one line) since it detects a tty,
that's ok.
note also that in this case, the script needs to be killed to finish,
since the wheel is not deleted, and thus poe won't shut the session down.
Subject: | run.pl |
#!/usr/bin/perl
use strict;
use warnings;
use POE;
use POE::Wheel::Run;
POE::Session->create(
inline_states => {
_start => \&_start,
stdout => sub { print "stdout: " . $_[ARG0] . "\n"; },
stderr => sub { print "stderr: " . $_[ARG0] . "\n"; },
close => \&close,
reap => \&reap,
}
);
POE::Kernel->run;
sub _start {
my ($k, $h) = @_[KERNEL, HEAP];
$k->alias_set('test');
my $wheel = POE::Wheel::Run->new(
Program => "ls /",
CloseEvent => 'close',
StdoutEvent => 'stdout',
StderrEvent => 'stderr',
#Conduit => 'pty-pipe',
);
$k->sig( CHLD => 'reap' );
$h->{wheel} = $wheel;
my $id = $wheel->ID;
my $pid = $wheel->PID;
print "wheel $id started (pid $pid)\n";
}
sub close {
my ($h, $id) = @_[HEAP, ARG0];
print "wheel $id stopped\n";
delete $h->{wheel};
}
sub reap {
my $pid = $_[ARG1];
print "pid reaped: $pid\n";
}