Signal Safety
Before v5.8, Perl attempted to treat signals like an interrupt and handle them immediately, no matter what state the interpreter was in. This was inherently unreliable because of reentrancy issues. Perl’s own memory could become corrupted and your process could crash, or worse.
Today, when a signal arrives for your process, Perl just marks a
bit that says it’s pending. Then at the next safe point in the
interpreter loop, all pending signals are processed. This is all safe
and orderly and reliable, but it is not necessarily timely. Some of
Perl’s opcodes can take a long time to execute, such as calling sort on an extremely large list.
To get Perl to return to handling (or mishandling) signals the
old, unreliable way, set your PERL_SIGNALS
environment variable to “unsafe”. You
had best read the section on “Deferred Signals” in the perlipc
manpage first, though.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access