xref: /netbsd-src/usr.bin/timeout/timeout.1 (revision f2d4de93b11cc398649ce949e24df4d95a0f367f)
1.\"	$NetBSD: timeout.1,v 1.5 2022/12/13 13:25:36 kre Exp $
2.\"
3.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD: head/usr.bin/timeout/timeout.1 268861 2014-07-18 22:56:59Z bapt $
28.\"
29.Dd December 13, 2022
30.Dt TIMEOUT 1
31.Os
32.Sh NAME
33.Nm timeout
34.Nd run a command with a time limit
35.Sh SYNOPSIS
36.Nm
37.Op Fl Fl signal Ar sig | Fl s Ar sig
38.Op Fl Fl preserve-status | Fl p
39.Op Fl Fl kill-after Ar time | Fl k Ar time
40.Op Fl Fl foreground | Fl f
41.Ao Ar duration Ac
42.Ao Ar command Ac
43.Ao Ar args ... Ac
44.Sh DESCRIPTION
45.Nm
46starts the
47.Ar command
48with its
49.Ar args .
50If
51.Ar command
52is still running after
53.Ar duration ,
54it is killed.
55By default,
56.Dv SIGTERM
57is sent.
58.Bl -tag -width "-k time, --kill-after time"
59.It Fl p , Fl Fl preserve-status
60Always exits with the same status as
61.Ar command
62even if it times out.
63.It Fl f , Fl Fl foreground
64Do not propagate timeout to the
65.Ar command
66children.
67.It Fl s Ar sig , Fl Fl signal Ar sig
68Specify the signal to send on timeout.
69By default,
70.Dv SIGTERM
71is sent.
72.It Fl k Ar time , Fl Fl kill-after Ar time
73Send a second kill signal if
74.Ar command
75is still running after
76.Ar time
77after the first signal was sent.
78.El
79.Sh DURATION FORMAT
80.Ar duration
81and
82.Ar time
83can be integer or decimal numbers.
84Values without unit symbols are interpreted as seconds.
85.Pp
86Supported unit symbols are:
87.Bl -tag -width indent -compact
88.It s
89seconds
90.It m
91minutes
92.It h
93hours
94.It d
95days
96.El
97.Sh EXIT STATUS
98If the timeout was not reached, the exit status of
99.Ar command
100is returned.
101.Pp
102If the timeout was reached and
103.Fl Fl preserve-status
104is set, the exit status of
105.Ar command
106is returned.
107If
108.Fl Fl preserve-status
109is not set, an exit status of 124 is returned.
110.Pp
111If
112.Ar command
113exits after receiving a signal, the exit status returned is the signal number plus 128.
114.Sh SEE ALSO
115.Xr kill 1 ,
116.Xr signal 3
117.Sh HISTORY
118A
119.Nm
120utility appeared in a development branch of
121.Fx 11
122and was imported into
123.Nx 7 .
124The
125.Fx
126work is compatible with GNU
127.Nm
128by
129.An Padraig Brady ,
130from GNU Coreutils 8.21.
131The
132.Nm
133utility first appeared in GNU Coreutils 7.0.
134