Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: trying to get timeout to work

by halfcountplus (Hermit)
on Apr 11, 2012 at 14:03 UTC ( #964542=note: print w/replies, xml ) Need Help??

in reply to trying to get timeout to work

It's because of the eval. Throw this in after you declare $h:

local $SIG{ALRM};
And see what happens.

Replies are listed 'Best First'.
Re^2: trying to get timeout to work
by Eliya (Vicar) on Apr 11, 2012 at 14:20 UTC

    The problem with this is that the alarm signal will then simply kill the script... (which is the default action for SIGALRM)

      Yes, but it will happen in the requested 3 seconds. If you want a non-fatal handler:

      local $SIG{ALRM} = sub { print STDERR "hey\n" };
      Ie, there is a difference in behaviour between that and set_sig_handler(). Whoops, no there isn't, but adding STDERR reporting does shed some light on when the alarm fires...

        Have you tried it?   AFAICT, this still doesn't do what the OP wants.

        Instead of the script getting killed, when the alarm fires, it now prints "hey" to STDERR, and then still goes to wait 60 seconds until the suprocess completes by itself.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964542]
[Corion]: Huh? That's weird indeed... Also, I thought that the olympic games were over already, but obviously not ;)
[choroba]: And we lost to unknown sportspersons with no official dresses
[choroba]: Russia didn't send them officially, they're on vacation in Korea
[LanX]: no that was Syria! ;-)
[LanX]: And the reason is: The world’s best players aren’t at this year’s Games after the NHL stopped its athletes from leaving in the middle of the season. ... LOL
[LanX]: horoba: you like ice hockey?
[choroba]: Like is a too strong word. But you can't evade it here.
LanX (for people wondering: yes field hockey still exists and is even more popular than Hasslhoff in Germany)
[Corion]: LanX: Ah, that explains a lot :)
[marto]: Nobody we spoke to in Berlin had a clue who Hasslhoff was

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2018-02-23 16:28 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (303 votes). Check out past polls.