in reply to Re: Signal handling in embedded Perl ?
in thread Signal handling in embedded Perl ?

Just for example's sake, something like this?
sub install_handler { my ($sig, $subref) = @_; my $original = $SIG{$sig} || sub{}; $SIG{$sig} = sub { $subref->(); $original->(); } }

Replies are listed 'Best First'.
Re^3: Signal handling in embedded Perl ?
by jbert (Priest) on Nov 21, 2006 at 16:19 UTC
    That would be the equivalent in perl, yes.

    But when embedding perl inside another program/platform, you'd be doing the same thing at the C level, and calling the POSIX sigaction() function (or its equivalent).

    (At least I think you would - I'd be very suprised if the existing value of $SIG{FOO} you stored in $original was a callable C function. But then, I've been surprised before).

    And being in C not perl, you wouldn't have the convenience of having a nice closure to capture your state, so you'd need to have a data structure (perhaps a global array indexed by signal number).