Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: trying to get timeout to work

by Eliya (Vicar)
on Apr 11, 2012 at 14:20 UTC ( #964547=note: print w/replies, xml ) Need Help??


in reply to Re: trying to get timeout to work
in thread trying to get timeout to work

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

Replies are listed 'Best First'.
Re^3: trying to get timeout to work
by halfcountplus (Hermit) on Apr 11, 2012 at 14:38 UTC

    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.

        Have you tried it?

        Yes. But I didn't add a print into the OP's handler, or a die into mine, which is why they seemed different due to the wait behaviour you describe. ;)

        All apologies, will edit.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964547]
help
Chatterbox?
[Corion]: Eily: Yeah - my French isn't even good to understand jokes, much less to make them :-D
[Corion]: marto: That post is a repost/duplicate of Excel sheet data write issue :-D
[Corion]: Whoops - Merging worksheets in .xls in one Excel sheet
[marto]: Corion, whoops, can the moderation me amended?
[Corion]: marto: We could vote, unconsider and reconsider ;)
[Corion]: "vote keep", I meant ;)
[Corion]: marto: But that aside, I hope you are well!
Corion is slowly acclimatizing to working only four days a week
[marto]: the back pain is still there, it's been a rough week, trying to do building work with a bad back
[Corion]: marto: Ow! That doesn't sound good :-/ The work won't help your back...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-09-21 14:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (248 votes). Check out past polls.

    Notices?