Signals? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Signals?

ShinobiC0deShinobiC0de Posts: 6Member
[b][red]This message was edited by ShinobiC0de at 2004-1-18 13:47:5[/red][/b][hr]
Is there any way to "catch" signals sent to a perl program like SIGTERM or SIGKILL? In C there is the signal() call, which could catch a signal and send it to a function for further processing, is there some equivalent of this in Perl?

Comments

  • JonathanJonathan Posts: 2,914Member
    : Is there any way to "catch" signals sent to a perl program like
    : SIGTERM or SIGKILL? In C there is the signal() call, which could
    : catch a signal and send it to a function for further processing, is
    : there some equivalent of this in Perl?
    Yup, you assign a callback to that signal using the %SIG hash. For example:-

    [code]# This sub is the handler.
    sub sigint {
    print "Got a SIG INT
    ";
    }

    # Now we set it up as the SIG INT callback.
    $SIG{'INT'} = &sigint;
    [/code]

    I also looked up the appropriate page on PerlDoc for you:-
    http://www.perldoc.com/perl5.8.0/pod/perlipc.html#Signals

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.