in reply to Interrupt Signal Handler

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

Replies are listed 'Best First'.
Re: Re: Interrupt Signal Handler
by bobn (Chaplain) on Jul 13, 2003 at 02:36 UTC

    In particluar, the 3rd edition of camel advises against print (pg.413)

    --Bob Niederman, http://bob-n.com