Subject: | Use of sudo in POE::Wheel::Run causes a stall. |
See Attached sample program.. Using sudo to execute a command via the
Program argument to POE::Wheel::Run causes the program to stall. Simply
removing sudo, fixes the problem. Suspecting a subshell issue, I
created a script which called bash as a login shell and executed the
command. Calling that script in POE runs fine. Apparently there is
something not successfully happening with POE::Wheel::Run and sudo..
also tried playing with NoSetSid and NoSetPgrp to no avail. Verified on
#poe@irc.perl.org to be reproducible.
Tested with 1.007 and 1.021 on CentOS 5.3 with Perl 5.8.8.
Subject: | POE-sudo.pl |
#!/usr/bin/perl
use strict;
use warnings;
use POE qw(
Wheel::Run
Filter::Line
);;
POE::Session->create( inline_states => {
_start => \&processor_start,
_stop => sub { },
run_lsof => \&processor_run_lsof,
lsof_line => \&processor_show_line,
lsof_close => \&processor_lsof_close,
});
POE::Kernel->run();
sub processor_start {
my ($kernel,$heap) = @_[KERNEL,HEAP];
$kernel->alias_set( 'processor' );
$kernel->yield( 'run_lsof' );
}
sub processor_run_lsof {
my ($kernel,$heap) = @_[KERNEL,HEAP];
my @CMD = qw(/usr/bin/sudo /usr/sbin/lsof -i -n);
print "Running @CMD\n";
$heap->{lsof_job} = POE::Wheel::Run->new(
Conduit => 'pty-pipe',
Program => \@CMD,
StdioFilter => POE::Filter::Line->new(),
StderrFilter => POE::Filter::Line->new(),
StdoutEvent => 'lsof_line',
StderrEvent => 'lsof_line',
CloseEvent => 'lsof_close',
);
print " + Job Started.\n";
}
sub processor_show_line {
my ($kernel,$heap,$line) = @_[KERNEL,HEAP,ARG0];
print "got: $line\n";
}
sub processor_lsof_close {
my ($kernel,$heap) = @_[KERNEL,HEAP];
print "Job Done\n";
$kernel->delay_add( 'run_lsof', 60 );
}