Sure. Tested using the below using Active State binary build 1204 (v5.12.3) built for x86_64-linux-thread-multi. This is a Fedora machine.

For some reason, on my Windows XP, Active State v 5.10.1 build 1007 MSWin32-x86-multi-thread, the same code hangs. The alarm() appears to just disappear. Odd. There is often something special about windows. Don't know why this is happening or rather not happening at the moment, but Linux is fine.

Update: I've seen this work on Windows before. Since both machines are running binary Active State builds, I'll retest when I get the Windows machine up to 5.12 along with the latest versions of the modules that I currently have installed. This upgrade is some months in the future...

#!/usr/bin/perl use warnings; use strict; $SIG{ALRM} = sub { die "timeout!!! alarm\n" }; alarm(5); #start the timer print "waiting for alarm..hit any key..."; <STDIN>; print "waiting for another input line"; <STDIN>; print "past the IO stuff, normal exit\n"; __END__ should see this if no key at all is hit waiting for alarm..hit any key...timeout!!! alarm

In reply to Re^3: Detecting Timeout of piped data by Marshall
in thread Detecting Timeout of piped data by sriordan

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.