[svn:perlfaq] r9875 - perlfaq/trunk
[email protected] Thu, 23 Aug 2007 13:04:54 -0700 (PDT)
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
Author: comdog Date: Thu Aug 23 13:04:53 2007 New Revision: 9875 Modified: perlfaq/trunk/perlfaq8.pod Log: * perlfaq8: How do I set CPU limits? + [email protected] fill out the answer, replaceing "use BSD::Resource" with a full explanation. Modified: perlfaq/trunk/perlfaq8.pod ============================================================================== --- perlfaq/trunk/perlfaq8.pod (original) +++ perlfaq/trunk/perlfaq8.pod Thu Aug 23 13:04:53 2007 @@ -1030,8 +1030,24 @@ Check the documentation for your specific version of Perl. =head2 How do I set CPU limits? +X<BSD::Resource> X<limit> X<CPU> -Use the BSD::Resource module from CPAN. +(contributed by Xho) + +Use the C<BSD::Resource? module from CPAN. As an example: + + use BSD::Resource; + setrlimit(RLIMIT_CPU,10,20) or die $!; + +This sets the soft and hard limits to 10 and 20 seconds, respectively. +After 10 seconds of time spent running on the CPU (not "wall" time), +the process will be sent a signal (XCPU on some systems) which, if not +trapped, will cause the process to terminate. If that signal is +trapped, then after 10 more seconds (20 seconds in total) the process +will be killed with a non-trappable signal. + +See the C<BSD::Resource> and your systems documentation for the gory +details. =head2 How do I avoid zombies on a Unix system?