Dear Monks,

I spent quite some time today on how to disable ctrl-break on Win32 (Windows XP SP2 Perl 5.6.1 built 630).
The code snippet below is based upon the great manual 'Perl by example' written by David Medinets to whom all the honours.

However I took the liberty to illustrate it a bit and to add a small erratum which costed me some time to figure out.
Hopefully this will save someone else a lot of aggrevation.

DDN.
# Possibility 1: Just set the IGNORE flag for the signal at the # beginning of the script. #$SIG{'BREAK'} = 'IGNORE'; #$SIG{'INT'} = 'IGNORE'; for ($x = 0; $x < 10; $x++) { # Possibility 2: Set the flag to redirect towards the INT_handler # function. # Remark: After having called the function, the flag is reset # to an UNDEF-like value. # $SIG{'BREAK'} = 'INT_handler'; # $SIG{'INT'} = 'INT_handler'; print("$x\n"); sleep 1; } # Possibility 1: Just set the DEFAULT flag for the signal at the # beginning of the script. #$SIG{'BREAK'} = 'DEFAULT'; #$SIG{'INT'} = 'DEFAULT'; sub INT_handler { print("Don't Interrupt!\n"); } # # Errata below obtained through 'print %SIG;' # concerning documentation located at # http://www.webbasedprogramming.com/Perl-5-By-Example/ch13.htm # and other locations on the web # ABRT This signal means that another process is trying to abort # your process. # ALRM # BREAK This signal indicates that a Ctrl+Break key sequence was # pressed under Windows. # CHLD # CLD # CONT # FPE This signal catches floating point exceptions. # IGNORE # ILL This signal indicates that an illegal instruction has been # attempted. # NUM01 # NUM05 # NUM06 # NUM07 # NUM10 # NUM12 # NUM16 # NUM17 # NUM18 # NUM19 # NUM24 # QUIT # SEGV This signal indicates that a segment violation has taken # place. # STOP # TERM This signal means that another process is trying to terminate # your process. # __WARN__ # int This signal indicates that a Ctrl+C key sequence was pressed # under Windows. # kill # pipe # instead of # ABRT2 This signal means that another process is trying to abort # your process. # BREAK2 This signal indicates that a Ctrl+Break key sequence was # pressed under Windows. # FPE2 This signal catches floating point exceptions. # ILL2 This signal indicates that an illegal instruction has been # attempted. # INT2 This signal indicates that a Ctrl+C key sequence was # pressed under Windows. # SEGV2 This signal indicates that a segment violation has taken # place. # TERM2 This signal means that another process is trying to # terminate your process.

In reply to How to disable ctrl-break on Win32 (Windows XP SP2 Perl 5.6.1 built 630) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.