Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl syntax for enforcing time limits

by Starky (Chaplain)
on Apr 22, 2001 at 01:59 UTC ( [id://74481]=note: print w/replies, xml ) Need Help??


in reply to Perl syntax for enforcing time limits

Very useful!

I have a suggestion: I would mention in the PODs that the sigalrm is used to establish the timeout. Almost every module that has a timeout uses a sigalrm to accomplish the task, and when they're used in combination, strange things happen. (Usually, the last assignment to $SIG{ALRM} overriders any former assignments.)

This would pose problems to those who use Net::Ping, for example, and less seasoned coders may not be aware of what is happening.

I'm going to keep this in my toolkit. I think it will see good use.

  • Comment on Re: Perl syntax for enforcing time limits

Replies are listed 'Best First'.
Re: Re: Perl syntax for enforcing time limits
by ncw (Friar) on Apr 22, 2001 at 05:08 UTC
    Glad you like it!

    Yes I should make the fact that it uses $SIG{ALRM} explicit in the documentation. However note that TimeLimit always uses local $SIG{ALRM} which means that it gets reset to its previous value when it goes out of scope.

    The answer to Net::Ping of course is that it should use TimeLimit too if it uses alarm(), or if you have some code that you think might be using alarm() &or $SIG{ALRM} and not resetting it then bracket it in a time_limit { } block and that will reset the alarm() & $SIG{ALRM} properly.

    Ideally I should submit TimeLimit so CPAN so everyone who uses alarm() anywhere should use it instead!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://74481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found