i'm trying to jump out of an eval block if it takes too long to execute, so i've been searching for a way to signal an alarm on Win32.

the typical way to accomplish this is by using the perl alarm function. here's a simple example from section 5.6 of 'advanced perl programming:'

$SIG{ALRM} = \&timed_out; eval { alarm (10); $buf = <>; alarm(0); # Cancel the pending alarm if user responds. }; if ($@ =~ /GOT TIRED OF WAITING/) { print "Timed out. Proceeding with default\n"; .... } sub timed_out { die "GOT TIRED OF WAITING"; }
this is all well an good for *NIX systems, but Win32 doesn't implement alarm. (see Alarm Implemented in Win32? for details.) curiously, Win32 does implement SIGALARM. consider:

C:\>perl -e "print join ' ', keys %SIG" STOP NUM05 NUM06 ALRM NUM07 NUM24 NUM16 NUM17 NUM18 NUM19 ILL CHLD SEG +V PIPE CLD ABRT CONT INT QUIT KILL BREAK TERM NUM01 FPE NUM10 NUM12
yep, $SIG{ALRM} is a valid key in %SIG. but is it really?

i don't know enough about signals to be able to use a magic number or password to signal an ALRM. i don't know if it is even possible on Win32. if not, is there some other way for me to break out of an eval block before an operation has completed?

~Particle


In reply to ALRMing behavior on Win32 by particle

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.