Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.