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")

In reply to Re: Win32 Interrupts by tye
in thread Win32 Interrupts by Adam

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.