Search code examples
perl

What is the 'DEFAULT' behaviour for perl signals?


The perlipc doc, section Signals, states amongst other things:

You may also choose to assign the strings "IGNORE" or "DEFAULT" as the handler, in which case Perl will try to discard the signal or do the default thing.

Now I've read up all sorts of things with regards to how to add a custom handler for different signals, how to ignore the signal and how to restore the 'DEFAULT' behaviour. My question, however, is: What exactly is the 'DEFAULT' behaviour for the different signals? Where can I look this up? Is that defined anywhere (at least by platform)? So far I have been unlucky in my search for more in-depth docs.

I'm trying to figure out what exactly the perl interpreter does in my case when I press CTRL+c if it e.g. calls the destructor on all objects or if it simply exits then and there.


Solution

  • A signal set to default means that the perl interpreter itself doesn't catch or handle that signal: the behaviour of the perl process is whatever the standard OS behaviour for that signal is. Generally, it means that the process immediately exits (possibly with a coredump), but with no cleanup actions, neither at the language level (END blocks, destructors, etc), nor at the process level. A few signals are ignored by default, and a few cause the process to be suspended (such as SIGSTOP).

    On Linux, 'man 7 signal' provides a table of the default action of each signal. Other OSes presumbaly provide similar lists, and for POSIX ans UNIX-alike OSes, most standard signals will have the same default behaviour as for Linux.