I wrote a Windows keyboard handler by the aid of module Win32::Console. I capture $SIG{INT} because ctrl-C shall be received as a normal character, which works fine.
However, when I call my perl program from a Windows batch, the latter at termination of the perl subtask asks whether the batch shall be terminated. The interrupt is ignored by the perl program but it's still there.
How can I flush the interrupt, not just ignore it?
Sample code illustrating the problem:
Now call the perl program, e.g. named "sigint.pl", from a batch program "sigint.bat" set up as follows:use Win32::Console; $keyboard = Win32::Console->new(STD_INPUT_HANDLE); $SIG{'INT'} = sub { print "Gotcha!\n"; exit 0 }; $| = 1; # autoflush input print("Press ctrl-C to exit\n"); while (1) { @in = $keyboard->Input(); print(chr($in[5])) if $in[1]; }
Thanks for any hint and best regards@echo off perl sigint.pl
In reply to How to Flush SIGINT on Win32? by herqles
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |