Interrupts in pre-5.8.0 perls are unsafe. They happen at the C-level, and not the Perl-level, meaning they can fire when Perl is half way of executing an "op". Which means that &quitting can be fired when the Perl internals are halfway being modified. But you will be doing things that assume the internals are consistent, valid and in order. Furthermore, you are doing things in your signal handler that causes Perl to do things at the C-level that are unsafe to use, even at the C-level. Allocation of memory is such a thing.

If you use a signal handler, do as little as possible in the handler, and try to avoid doing any action that requires Perl to allocate memory, or to call functions that are not reentrant.

This all sounds very low level, and very "out of Perl". And it is. Signals live at the C-level, and you really have to know what's going at the C-level to understand pre-5.8.0 signals.

You might want to read up on signals in Stevens' Advanced Programming in the UNIX Environment, IMO more useful than any Perl book if you want to understand the interaction between Perl and the underlaying system (the C-level).

Abigail


In reply to Re: Interrupt Signal Handler by Abigail-II
in thread Interrupt Signal Handler by bayruds

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.