|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re: system() with timeoutby Abigail-II (Bishop) |
| on Mar 18, 2004 at 10:52 UTC ( [id://337710]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
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
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||