Did you copy and paste that code, or attempt to retype it?

$ perl temp.pl String found where operator expected at temp.pl line 13, near "d 'Time +out on read'" (Do you need to predeclare d?) syntax error at temp.pl line 13, near "d 'Timeout on read'" Missing right curly or square bracket at temp.pl line 16, at end of li +ne syntax error at temp.pl line 16, at EOF Execution of temp.pl aborted due to compilation errors.

update: Ah, now (with your sub d) I get 100% CPU utilization, for much longer than a second, which I guess is probably similar to what you're getting, and which is presumably not what you want. So yeah, it appears the problem is not just something weird with your local setup, which is what I was trying to confirm. I threw in an extra warn and confirmed that $paddr is always undef, but I imagine what you're trying to do is limit execution time when there's no connection. Hmmm... select undef,undef,undef,$delay can measure fractional parts of a second, but I don't know how small its resolution goes. That would also stop you from consuming 100% CPU, though: just loop through $n tries with $totaltimelimit/$n delay each time. Would that work?

$ perl -v This is perl, v5.8.7 built for i386-freebsd-64int (with 2 registered patches, see perl -V for more detail) Copyright 1987-2005, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge.

I wanted to help you out by testing your code on another FreeBSD system, but I think there's more wrong than $SIG{ALRM} only.


Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. Why, I've got so much sanity it's driving me crazy.

In reply to Re: $SIG{'ALRM'} on FreeBSD by jonadab
in thread $SIG{'ALRM'} on FreeBSD by b888

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.