version 1.1, 2021/09/01 15:50:33 |
version 1.2, 2021/09/02 21:50:24 |
|
|
|
.\" $OpenBSD$ |
.\" $NetBSD: timeout.1,v 1.4 2016/10/13 06:22:26 dholland Exp $ |
.\" $NetBSD: timeout.1,v 1.4 2016/10/13 06:22:26 dholland Exp $ |
.\" |
.\" |
.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org> |
.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org> |
|
|
.\" |
.\" |
.\" $FreeBSD: head/usr.bin/timeout/timeout.1 268861 2014-07-18 22:56:59Z bapt $ |
.\" $FreeBSD: head/usr.bin/timeout/timeout.1 268861 2014-07-18 22:56:59Z bapt $ |
.\" |
.\" |
.Dd July 19, 2014 |
.Dd $Mdocdate$ |
.Dt TIMEOUT 1 |
.Dt TIMEOUT 1 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
|
|
.Nd run a command with a time limit |
.Nd run a command with a time limit |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm |
.Nm |
.Op Fl Fl signal Ar sig | Fl s Ar sig |
.Op Fl k Ar time |
.Op Fl Fl preserve-status |
.Op Fl s Ar sig |
.Op Fl Fl kill-after Ar time | Fl k Ar time |
.Op Fl -foreground |
.Op Fl Fl foreground |
.Op Fl -preserve-status |
.Ao Ar duration Ac |
.Ar duration |
.Ao Ar command Ac |
.Ar command |
.Ao Ar args ... Ac |
.Op Ar args |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
|
The |
.Nm |
.Nm |
starts the |
utility executes |
.Ar command |
.Ar command , |
with its |
with any |
.Ar args . |
.Ar args , |
|
and kills it if it is still running after the |
|
specified |
|
.Ar duration . |
If |
If |
.Ar command |
.Ar duration |
is still running after |
is 0, the timeout is disabled. |
.Ar duration , |
.Pp |
it is killed. |
The options are as follows: |
By default, |
.Bl -tag -width Ds |
.Dv SIGTERM |
.It Fl k Ar time , Fl -kill-after Ns = Ns Ar time |
is sent. |
Send a second kill signal if the command is still running |
.Bl -tag -width "-k time, --kill-after time" |
|
.It Fl Fl preserve-status |
|
Always exits with the same status as |
|
.Ar command |
|
even if it times out. |
|
.It Fl Fl foreground |
|
Do not propagate timeout to the |
|
.Ar command |
|
children. |
|
.It Fl s Ar sig , Fl Fl signal Ar sig |
|
Specify the signal to send on timeout. |
|
By default, |
|
.Dv SIGTERM |
|
is sent. |
|
.It Fl k Ar time , Fl Fl kill-after Ar time |
|
Send a second kill signal if |
|
.Ar command |
|
is still running after |
|
.Ar time |
.Ar time |
after the first signal was sent. |
after the first signal was sent. |
|
.It Fl s Ar sig , Fl -signal Ns = Ns Ar sig |
|
Specify the signal to send on timeout, instead of the default |
|
.Dv SIGTERM . |
|
.It Fl -foreground |
|
Do not propagate the timeout signal to children processes. |
|
.It Fl -preserve-status |
|
Always exit with the same status as |
|
.Ar command , |
|
even if the timeout was reached. |
.El |
.El |
.Sh DURATION FORMAT |
.Sh DURATION FORMAT |
.Ar duration |
.Ar duration |
and |
and |
.Ar time |
.Ar time |
can be integer or decimal numbers. |
may contain a decimal fraction. |
Values without unit symbols are interpreted as seconds. |
The value defaults to seconds unless a unit suffix is given. |
.Pp |
.Pp |
Supported unit symbols are: |
The supported unit suffixes are: |
.Bl -tag -width indent -compact |
.Pp |
|
.Bl -tag -width Ds -offset indent -compact |
.It s |
.It s |
seconds |
seconds |
.It m |
.It m |
|
|
is returned. |
is returned. |
.Pp |
.Pp |
If the timeout was reached and |
If the timeout was reached and |
.Fl Fl preserve-status |
.Fl -preserve-status |
is set, the exit status of |
was set, the exit status of |
.Ar command |
.Ar command |
is returned. |
is returned. |
If |
If |
.Fl Fl preserve-status |
.Fl -preserve-status |
is not set, an exit status of 124 is returned. |
was not set, an exit status of 124 is returned. |
.Pp |
.Pp |
If |
If |
.Ar command |
.Ar command |
exits after receiving a signal, the exit status returned is the signal number plus 128. |
exited after receiving a signal, the exit status returned is the signal number |
|
plus 128. |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr kill 1 , |
.Xr kill 1 , |
.Xr signal 3 |
.Xr signal 3 |