Perl, POE and the pesky reaper
If you’re like me, you might be using POE (Perl Object Environment) for Perl in your applications. Using Wheel::Run is quite easy once you realize that it is just a big event loop. The documentation is quite sparse but unless you look carefully, you might overlook how to avoid the “Child process PID:26862 reaped” messages that occur when your application finishes.
Yup, it bit me too. The solution is to set up a child signal handler in the POE kernel and not in the global namespace as you would normally do.
Here we add the child signal handler, we pretty much ignore it in this code but we might flesh it out with some meaningful messages or something. Note that “$poe_kernel->sig_handled();” tells the POE kernel that this particular signal has been handled.
$poe_kernel->sig_handled();
}
$poe_kernel->sig(CHLD => \\&signal_child);
Notice that to handle the interrupt signal (ctrl-c), we need to use the global handler so that we can close down the application:
print "\\n\\nERROR: Aborting on interrupt signal\\n";
exit -1;
}
$SIG{INT} = \\&signal_int;
That’s it



Recent Comments