To implement a hard timeout, the function
alarm() is available in C, Perl, and other programming languages, which normally calls the system functon of the same name (see
man 2 alarm). For the Perl
alarm() function, the timeout is specified in seconds:
# ... GetOptions ... alarm($timeout); # ... core code ... alarm(0); # ... end
alarm($timeout) call starts the alarm function, the argument
0 for the second call stops it again. The first call should be used before time-intensive processing steps, in network-based plugins before opening sockets, and similar situations where a long delay may occur. A good place is after the command line has been processed via
At the end of the plugin it is recommended that you ...