in reply to Win32 Interrupts

Well, I did find a way to make it work under Win32 (tested under Win98 and WinNT). This seems to indicate several bugs in Perl 5.6.0 for Win32. But first, the code that works:

# The following hack allows $SIG{INT} to work under Win32: my $child= fork(); if( defined $child && 0 == $child ) { # Child: exit( 0 ); } # Parent: my $go= 1; $SIG{INT}= sub { $go= 0; warn "Got INT\n" }; my $i= 0; while( $go && $i < 10_000_000 ) { $i++; } print "Done: $i\n";

Now, I recall reading that $$ is supposed to be negative for the threads that are created by Win32 Perl's pseudo-fork(). But in coming up with the above code I found that $$ is negative in the parent and positive in the child. kill and waitpid seem to return immediately after doing nothing. The parent exit()ing sometimes kills the "child" thread and sometimes lets it run. I even had a case where CTRL-C caused the parent to start over (and no, I quadruple-checked that it wasn't the child acting like the parent).

And 2 of 4 times using this code and hitting CTRL-C caused Perl to panic under WinNT (no panics after dozens of runs under Win98 -- Win98 doesn't care nearly as much if your code goes romping mearilly through random chunks of RAM).

Anyone been keeping up with p5p and know how much of this is already know to the developers. I would think most of this is since it so easy to find and they'd be intersted in testing the new pseudo-fork(). tilly? :)

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
RE (tilly) 2: Win32 Interrupts
by tilly (Archbishop) on Sep 20, 2000 at 15:34 UTC
    I keep up enough to have random tidbits, but I don't follow closely. Sorry. I think this should definitely be reported as a bug though. Ben