Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: system() with timeout

by Abigail-II (Bishop)
on Mar 18, 2004 at 15:52 UTC ( [id://337710]=note: print w/replies, xml ) Need Help??


in reply to system() with timeout

Don't do it with system directly, or you might generate zombies. fork(), do an exec() in the child, and then, in an eval block, setup an alarm handler that does a die(), set the alarm, waitpid() for your child, cancel the alarm. Outside the eval block, check for $@, if it indicates the alarm was triggered, kill the child and waitpid() for it.

No doubt there are some race conditions left in, but it's a start.

Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2025-06-18 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.