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.
  • Comment on How to disable ctrl-break on Win32 (Windows XP SP2 Perl 5.6.1 built 630)
  • Download Code