NAME

maxtime - run a command with a timeout


SYNOPSIS

maxtime [-g] [-k] [-v] [-w] [--] time command [arg1 ...]


DESCRIPTION

maxtime allows for an external program to be run with a time limit. The argument time must be a positive number of seconds, and may be fractional. If the command terminates within this period, maxtime reports its exit status. If the command's real (wall clock) time exceeds the time limit, it will be killed with SIGTERM. maxtime will then return the value 106 to indicate the timeout (see below under RETURN VALUE).


OPTIONS

-g
The specified command will run in its own process group. If the command times out, the entire process group will be killed.

-k
If SIGTERM does not kill command, send SIGKILL after a short delay.

-v
Be verbose. If not specified, maxtime will not report what it is doing, even if it exits due to an error. However, the exit code will indicate the problem.

-w
Wait for termination of the child process, even if it timed out and was sent a SIGTERM and/or SIGKILL.


ENVIRONMENT

PATH
PATH is traversed in order to find the specified command.


RETURN VALUE

maxtime returns the exit status of the external command, unless an error condition occurs, in which case the exit code will be greater than 100.

  1. The command completed successfully.

  2. to 100
  3. The command was unsuccessful. The exit status is the exit status of the external command.

  4. Too few commandline arguments.

  5. Invalid command line options.

  6. Error while setting the alarm signal handler.

  7. Error while forking child process.

  8. Error during exec(). Probably the command specified is not in the PATH.

  9. Either the command timed out and was killed, or some other process sent it a signal, causing it to terminate. The command did not return a useful exit status.

  10. Insufficient memory to perform requested task.

  11. The time specified was not a valid floating-point number.

  12. The specified timer period was negative or zero.

  13. The timer could not be set.

  14. and up
  15. The command was unsuccessful, and exited due to a signal (e.g. an interrupt was sent from the keyboard).


EXAMPLES

Request the status of a Baan shared memory segment, but do not lock up if shared memory is corrupt:

    maxtime 2 $BSE/bin/shmmanager6.1 -s

Allow at most 10 minutes for stopping a Baan software environment:

    maxtime 600 $BSE/etc/rc.stop


BUGS

If the time argument is omitted and an arg argument is provided, maxtime might interpret its commandline arguments wrong. This will only be apparent if -v has been used, or if its exit status is tested for value 105.

On some platforms, maxtime might confuse options for the external command as options for itself. In these cases is necessary to indicate the end of maxtime's options using --.


SEE ALSO

exit(3), setitimer(2), signal(7), wait(2).


VERSION

This manual pertains to version 0.35.


AUTHOR and COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the terms described by the GNU General Public License version 2.

maxtime is distributed without any warranty, even without the implied warranties of merchantability or fitness for a particular purpose.