Venerable ones,
The question is "what to do about those alarm timeouts we've been using pre-5.8?" For syscalls in 5.8, the opcode/XS code has to finish/raise a signal/time out before returning to our code, rendering our signal timeout setting ineffectual.
Illustration:
#!/usr/bin/perl -w use strict; use Time::HiRes qw( gettimeofday tv_interval ); print "$]\n"; my $elapsed = 0; my $start_time = [gettimeofday]; eval { local $SIG{ALRM} = sub { $elapsed = tv_interval( $start_time ); warn "alarm-timeout signal"; die; }; alarm(1); `ls -R / 2>/dev/null`; alarm(0); }; print "$@" if $@; print "$elapsed\n";
Output on 5.6:
5.006 alarm-timeout signal at /home/jbho/bin/test_SIGALRM.pl line 15. Died at /home/jbho/bin/test_SIGALRM.pl line 16. 0.999504
Output on 5.8:
5.008 alarm-timeout signal at /home/jbho/bin/test_SIGALRM.pl line 15. Died at /home/jbho/bin/test_SIGALRM.pl line 16. 109.948451
Suggestion put out by member(s) of the community:
use POSIX ':signal_h'; my $alarm = 0; sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 } or die "Error setting SIGALRM handler: $!\n";
This solution would bypass the perl implementation for setting the signal.
What say you?

In reply to How to deal with safe signals in 5.8.0? by jbho

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.