http://www.perlmonks.org?node_id=1016885


in reply to Re^3: how to use angle operator with timeout?
in thread how to use angle operator with timeout?

I know that they do not work on win32, and why.

My question was: can signals -- alarm generated or otherwise -- interrupt blocking IO on *nix in under the auspices of safe-signals?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^4: how to use angle operator with timeout?

Replies are listed 'Best First'.
Re^5: how to use angle operator with timeout?
by tmharish (Friar) on Feb 04, 2013 at 09:12 UTC

    This works on *nix:

    use strict ; use warnings ; my $timeout_in = 5 ; eval { local $SIG{ALRM} = sub { die "timed_out\n" }; alarm($timeout_in); while(<>) { alarm($timeout_in); my $in = $_ ; chomp( $in ) ; print $in . "\n" ; last if( $in eq 'exit' ); } alarm(0) ; }; if ($@) { die( "Hey ... whats with the slow typing ??\n" ); }

      Really? Actual tested code on which flavour of *nix & Perl please?

      Because that seems to contradict anonymonk's reading of the docs?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        OS:

        Linux MYCOMPNAME_REMOVED 3.5.0-23-generic #35-Ubuntu SMP Thu Jan 24 13 +:15:40 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

        Perl:

        Summary of my perl5 (revision 5 version 14 subversion 2) configuration +: Platform: osname=linux, osvers=3.2.0-23-generic, archname=x86_64-linux-gnu-t +hread-multi uname='linux komainu 3.2.0-23-generic #36-ubuntu smp tue apr 10 20 +:39:51 utc 2012 x86_64 x86_64 x86_64 gnulinux '

        I should add that I use this on production servers on multiple flavors of Ubuntu and have been using this ( Not completely sure here ) since Perl 5.08 or so - definitely works on 5.10 as we have that on some servers.

Re^5: how to use angle operator with timeout?
by Anonymous Monk on Feb 04, 2013 at 02:39 UTC
      you should use

      That'll be tobyink and/or the OP that need to do that. Or maybe not? (Damn! It is hard to get a straight answer around here :()


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.