Quite unrelated: Are you sure you want to do that much in a signal handler?

sub int_handler { print "\n\n\t\t\tWe caught SIGINT; we are shutting down now...\n"; $SIG{INT} = \&int_handler; ### OTHER STUFF ### exit(1); }

The "better safe than sorry" approach towards signal handlers is to do as LESS as possible inside the signal handler and let the main program handle the situation. Remember that signals may interrupt EVERY system call. Typically, you would only set a flag inside the signal handler (e.g. $caughtSigInt=1 or just $stop=1), and check that flag inside the main loop (e.g. while (!$stop) { .... }).

Why do you setup int_handler as handler for SIGINT again inside int_handler? Is it cargo cult or intentionally? You would need that if you wanted to handle multiple SIGINTs (i.e. Ctrl-Cs) inside the same program, e.g because you want to (ab)use the SIGINT for something completely different (like updating a status line or terminating just a subroutine instead of the whole program). But if you want to exit the program, this makes no sense. Every SIGINT following the first one will effectively restart the routine.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: signal handling in exec()'d code by afoken
in thread signal handling in exec()'d code by jliv

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.