kansaschuck has asked for the wisdom of the Perl Monks concerning the following question:

After pressing lots off keys on my laptop to interrupt a Perl program running in a loop (ActiveState v5.10) I finally got a :
Terminated on signal SIGBREAK(21)
I'm not finding much doc on that. Is there a way to catch that Sig and control processing?

thank, KC

Replies are listed 'Best First'.
Re: Terminated on signal SIGBREAK(21)
by BrowserUk (Patriarch) on Mar 06, 2008 at 01:08 UTC
    Is there a way to catch that Sig and control processing?

    Yes. Add this to your program:

    local $SIG{ BREAK } = sub { print "Try harder sucker!" };;

    As far as I am aware, there are four trappable signals in Perl under win32:

    1. 21 - SIGBREAK. Generated from the keyboard by ^break.
    2. 2 - SIGINT. Generated from the keyboard by ^C.
    3. 3 - SIGQUIT.
    4. 15 - SIGTERM.

    Also the pseudo-signals __WARN__ and __DIE__.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.