In need of some arcane Perl lore...

I'm creating an embedded Perl library for an environment which has its own set of signal handlers. I can't seem to find an explicit description of how to safely merge Perl's (v5.8) signal handling with that environment (nothing mentioned in perlembed or perlcall). The nearest search hit I've found is Apache::SIG, but I'm ignorant of mod_perl internals.

Does anyone know of a reference to describe how to deal with signal handlers in such an environment ? I.e.,

Update/Clarification:

I'm writing a library to install a Perl interpretter into an existing application framework (ala mod_perl). Said framework has its own set of signal handlers, some of which have very important functions to safely rollback the actions of plugins (such as I'm writing), esp. wrt cleaning up memory.

However, if I rely on the framework's current signal handlers, which usually do some heap cleanup then longjmp() back to a known state, its quite likely that my embedded Perl will be left in a confused state. So I'd like to be able to use Perl's "safe" signal handling (dispatching between opcodes), and then rollback safely in an "eval-ish" sortof way. After which, I can dispatch back to the original signal handler.

Hence, I need to understand how an embedded Perl is going to treat existing signal handlers.

Final Empirical Update:

After hacking up some code to verify, here's the results: (WinXP, AS Perl 5.8, using SIGINT, using simple sleep() and simple print/printf() signal handler):

  1. Signal handler installed via C before starting Perl: reverts to default Perl behavior (immediately terminates)
  2. Signal handler installed via embedded Perl script: behaves as for standalone Perl script, ie, defers signal until sleep() ends
  3. Signal handler installed via C after starting embedded Perl, then eval a sleep script in Perl: behaves as for (1)
So it appears embedded Perl does commandeer signals on creation, but doesn't tinker with them afterward unless the Perl script explicitly does so.

Note that (3) is probably dangerous, as it presumably is equivalent to unsafe signals, ie, Perl possibly left in a bad state. I'll probably have to borrow Perl's signal queueing code to restore sanity.


In reply to Signal handling in embedded Perl ? by renodino

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.