Trying to get a sig child handler routine working. I'm using POE::Wheel::Run and used the sample close handler from the POE docs but it dies on me and kills off the job server. It appears to be working at first then it dies.
[task_result] Child process in wheel 8 wrote to STDOUT: HASH(0x9b22c94 +) [task_result] Result for cmd: 32240\Kb (1.5%). [irc_bot_msg] I said '[task_result] Result for cmd: 32240\Kb (1.5%).' +to swares [task_close] Child 30750 has finished. [on_child] We have lost our children! (POE::Session=ARRAY(0x8fcf1a0)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9adc6d0)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9ad16c4)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9b231f8)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9b23a50)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9ad8d1c)) [on_child] We have lost our children! (POE::Session=ARRAY(0x9adb2e8)) [bot_stop] Stopping. Can't call method "PID" on an undefined value at ./cookbot.pl line 169 +4.
# The signal handler -
# handler for child processes (forking job server) $kernel->sig( CHLD => "task_close" );
Where I call the code -
my $task = POE::Wheel::Run->new( Program => sub { &{$this_code} }, ProgramArgs => \@program_args, StdoutFilter => POE::Filter::Reference->new(), StdinEvent => 'task_stdin', # Flushed all data to the child's +STDIN. StdoutEvent => 'task_result', # Received data from the child's +STDOUT. StderrEvent => 'task_debug', # Received data from the child's S +TDERR. # ErrorEvent => 'task_error', # An I/O error occurred. CloseEvent => 'task_close', # Child closed all output handle +s. ); $heap->{task}->{ $task->ID } = $task;
Here's the task_close event handler -
# Child close event sub task_close { my ($heap, $wheel_id) = @_[HEAP, ARG0]; my $result = $_[ARG0]; my $child = $heap->{task}->{$wheel_id}; print "[task_close] Child ", $child->PID, " has finished.\n"; $child = delete $heap->{task}->{$wheel_id}; }

In reply to POE::Wheel::Run task_close handler problems. by swares

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.