hatimerun

Langue: en

Autres versions - même langue

Version: $Date: 2007/08/18 14:08:20 $ (fedora - 01/12/10)

Section: 1 (Commandes utilisateur)

NAME

hatimerun - Run command with a timeout.

SYNOPSIS

hatimerun [-a] [-e exitcode] [-k sig] -t secs command[args]
hatimerun [-l|-h|-?]

DESCRIPTION

Executes the given command with the given args with a timeout of secs seconds. If the new process doesn't terminate before a timeout of secs exceeds hatimerun sends the process a signal. The command is run in its own process group, the termination signal is sent to this process group. hatimerun will always wait for the child to terminate, even if the timeout occurred but the child didn't terminate on the signal. The hatimerun process which waits for the child to exit ignores the following signals: TERM, HUP, INT, PIPE, QUIT, USR1 and USR2.
-t secs
Specifies the time the command has to finish before a signal will be sent. Multiple occurrences of -t are supported. Every time a specified timeout happens a new signal is sent to the child. See EXAMPLES section for more info.
-k sig
Specifies the signal witch will be sent to the process group if a timeout occurs. Multiple occurrences of -k are supported. In case multiple -t arguments are specified every time a new timeout happens the next specified signal will be sent. if there are less -k arguments then -t arguments specified the missing signals are defaulted to SIGKILL. See EXAMPLES section for more info.

Default: SIGKILL

-e exitcode
Changes the exitcode returned by hatimerun on timeout (if the program ends normally or abnormally after the first signal was sent) to exitcode Multiple occurrences of -e are supported in connection with multiple occurrences of -t.

Default: 99

-a
Starts hatimerun in the background. The hatimerun program exits immediately. The return code of the executed command is lost.
-l
Prints list of available symbolic signal names on this platform and exits.
-h | -?
Prints a help screen and exits.

RETURN VALUE

If the command terminates normally before the first timeout happend, On success hatimerun returns the return value of the given command

After the first timeout happend hatimerun returns the value specified by the respective -e option or 99 per default. hatimerun will always wait for the program to terminate, even if the program terminates normally after the first signal was sent, hatimerun will return the respective error code as return value and the exit code of the command is lost.

EXAMPLES

hatimerun -t 5 sleep 10
Will kill the sleep command after 5 seconds

hatimerun -k TERM -t 5 sleep 10

Will send the TERM signal after 5 seconds

hatimerun -k TERM -t 5 -e 100 -e 101 -t 1 sleep 10

Will send the TERM signal after 5 seconds, and (if the command didn't finish till then) send the KILL signal one second later (about 6 seconds after program start). Will return 100 if the program was terminated by the TERM signal or 101 if it was terminated by the KILL signal.

hatimerun -k HUP -t 1 nohup sleep 1000

Will send a HUP signal after one second and then wait (potentially forever) until the child terminates.

AUTHOR

Copyright (c) 2001,2003,2005-2007 by Markus Winand <mws@fatalmind.com>

SEE ALSO

halockrun(1)