NAME
Sys::RunUntil - make sure script only runs for the given time
SYNOPSIS
use Sys::RunUntil '30m';
# code which may only take 30 minutes to run
DESCRIPTION
Provide a simple way to make sure the script from which this module is loaded, is running only for the given (wallclock) time.
METHODS
There are no methods.
RUNTIME SPECIFICATION
The maximum runtime of the script can be specified in seconds, or with any combination of the following postfixes:
- S seconds
- M minutes
- H hours
- D days
- W weeks
A runtime of "1H30M" would therefor indicate a runtime of 5400 seconds.
THEORY OF OPERATION
The functionality of this module basically depends on alarm
and fork
. When the "import" class method is called (which happens automatically with use
), that method sets an alarm
and then forks the process and waits for the process to return. If the process returns before the alarm
is activated, that's ok. If the alarm
is triggered, it means that the child process is taking to long: the parent process will then kill the child by sending it a TERM (15) signal.
REQUIRED MODULES
(none)
SEE ALSO
Sys::RunAlone, Sys::RunAlways.
AUTHOR
Elizabeth Mattijsen
COPYRIGHT
Copyright (c) 2005 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.