http://qs1969.pair.com?node_id=552515

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

Hey folks. I asked a question in the CB the other day, and thought via bart's help I had it solved. But as I play more I've run into more questions. Have looked around a bit (i.e., in 436492 and some of its links, and elsewhere) but really haven't found an explanation. I certainly apologize in advance if this has been answered in some obvious place.

To start with the obvious. On win32:

#!/usr/bin/perl use strict; use warnings; while (1) { print "still here...\n"; sleep 30; }

Pressing ctrl-C results in a (virtually) instantaneous:

Terminating on signal SIGINT(2)

Fine. Now this:

#!/usr/bin/perl use strict; use warnings; $SIG{INT} = \&handleit; while (1) { print "still here...\n"; sleep 30; } sub handleit { die "I caught it."; }

If I run this on my win32 system, and issue a ctrl-C, the handler does not display its expected response until after the sleep has finished (about 30 seconds later). On Linux, the sleep is broken immediately and the handler runs right away (as I would expect).

I'm confused. It seems that the first example shows that indeed a ctrl-C under win32 is (as expected) breaking into the sleep properly. If this is the case, where the heck has the program control gone in the second example? Where exactly are things between the time of the ctrl-C and when the sleep ends and the handler runs?

I'm on Windows XP Pro, SP 1. My Perl v5.8.7, ActiveState binary build 815.

Cheers,
Ken

Correction: Moved up my system info, and clarified sleep behavior.

"This bounty hunter is my kind of scum: Fearless and inventive." --J.T. Hutt