in reply to destroying/reaping a POE::Wheel

It sounds as if the program is exiting before all the child processes can be reaped. To avoid process leaks, POE will reap all outstanding attached child processes before exiting. The annoying warning is to let you know there's a problem. POE is often used in long-running daemons, where a silent process leak can lead to a mysteriously dead machine.

So, what can you do? Try sig_child() rather than sig() to reap specific process IDs. For example:

sub start_wheel { my $child = POE::Wheel::Run->new( ... ); $_[HEAP]{child} = $child; $_[KERNEL]->sig_child( $child->PID => "sig_child" ); }

The sig_child() method asks that an event be dispatched when a specific PID is reaped. In this case, the PID associated with a particular POE::Wheel::Run instance. sig_child() is more convenient than the blanket sig() handler. Also, a session waiting for a specific PID will be kept alive until that process is reaped. If my guess is correct, this last feature should avert your program's warnings.

sig_child() is documented in POE::Kernel, with the other POE::Kernel methods.

Replies are listed 'Best First'.
Re^2: destroying/reaping a POE::Wheel
by megamic (Sexton) on Sep 04, 2008 at 04:46 UTC

    Thanks, I tried two approaches based on your advice, and both worked!

    Putting a waitpid inside the sig_child handler worked as you suggested, however putting a 'do {} while (wait() > 0)' in the CloseEvent handler also did the trick. Im thinking the first method is better as it reaps earlier.

    Cheers