Esteemed Monks,

I am searching for a way to catch and handle a Control-C when using multiple POE sessions. I have successfully used the snippet from the POE Cookbook to actually catch the INT signal in each of my Sessions:

inline_states => { _connected => sub { my ($kernel, $session) = @_[KERNEL, SESSION]; ## Handle control-C $kernel->sig( INT => 'event_sigint' ); ... } # inline_states ... event_sigint => sub { my ($kernel, $session) = @_[KERNEL, SESSION]; print STDERR "Caught Control-C, shutting down gracefully.\ +n"; $kernel->yield("Shutdown",2,'Received break from user'); }, # event_sigint

In all but one of my sessions I simply catch the signal and print to STDERR a simple message giving the session alias. The above snippet is in only one of my sessions and I want to use it to do the graceful shutdown.

However, I am using POE::Component::SimpleDBI, which uses POE::Wheel::Run to fork a child process that does the 'heavy-lifting' as the POD puts it. What is happening is that somewhere in POE's reaping of the child process(es) created by POE::Component::SimpleDBI, the POE kernel itself is (or seems to be) stopping in its tracks.

Things I have tried:

#1 - manually adding an INT handler to SimpleDBI.pm
#2 - perusing kernel.pm and signals.pm for clues

I confess to the monks that this challenge is beyond me and I humbly submit the question for your review: is there a way to have POE reap the child process without dying immediately thereafter, allowing me to yield a shutdown subroutine to do the cleanup and exit?

Many thanks,

-MC


In reply to POE - Catching INT Signals by mercutio_viz

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.