xref: /netbsd-src/usr.bin/timeout/timeout.1 (revision f2d4de93b11cc398649ce949e24df4d95a0f367f)
1*f2d4de93Skre.\"	$NetBSD: timeout.1,v 1.5 2022/12/13 13:25:36 kre Exp $
23f7fdb96Schristos.\"
37a7434feSchristos.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
47a7434feSchristos.\" All rights reserved.
57a7434feSchristos.\"
67a7434feSchristos.\" Redistribution and use in source and binary forms, with or without
77a7434feSchristos.\" modification, are permitted provided that the following conditions
87a7434feSchristos.\" are met:
97a7434feSchristos.\" 1. Redistributions of source code must retain the above copyright
107a7434feSchristos.\"    notice, this list of conditions and the following disclaimer.
117a7434feSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
127a7434feSchristos.\"    notice, this list of conditions and the following disclaimer in the
137a7434feSchristos.\"    documentation and/or other materials provided with the distribution.
147a7434feSchristos.\"
157a7434feSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
167a7434feSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177a7434feSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
187a7434feSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
197a7434feSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
207a7434feSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
217a7434feSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
227a7434feSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
237a7434feSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
247a7434feSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
257a7434feSchristos.\" SUCH DAMAGE.
267a7434feSchristos.\"
277a7434feSchristos.\" $FreeBSD: head/usr.bin/timeout/timeout.1 268861 2014-07-18 22:56:59Z bapt $
287a7434feSchristos.\"
29*f2d4de93Skre.Dd December 13, 2022
307a7434feSchristos.Dt TIMEOUT 1
317a7434feSchristos.Os
327a7434feSchristos.Sh NAME
337a7434feSchristos.Nm timeout
347a7434feSchristos.Nd run a command with a time limit
357a7434feSchristos.Sh SYNOPSIS
367a7434feSchristos.Nm
3777ebce0bSwiz.Op Fl Fl signal Ar sig | Fl s Ar sig
38*f2d4de93Skre.Op Fl Fl preserve-status | Fl p
3977ebce0bSwiz.Op Fl Fl kill-after Ar time | Fl k Ar time
40*f2d4de93Skre.Op Fl Fl foreground | Fl f
417a7434feSchristos.Ao Ar duration Ac
427a7434feSchristos.Ao Ar command Ac
437a7434feSchristos.Ao Ar args ... Ac
447a7434feSchristos.Sh DESCRIPTION
457a7434feSchristos.Nm
467a7434feSchristosstarts the
477a7434feSchristos.Ar command
487a7434feSchristoswith its
497a7434feSchristos.Ar args .
507a7434feSchristosIf
517a7434feSchristos.Ar command
527a7434feSchristosis still running after
537a7434feSchristos.Ar duration ,
547a7434feSchristosit is killed.
557a7434feSchristosBy default,
56a76b73c7Sdholland.Dv SIGTERM
577a7434feSchristosis sent.
587a7434feSchristos.Bl -tag -width "-k time, --kill-after time"
59*f2d4de93Skre.It Fl p , Fl Fl preserve-status
607a7434feSchristosAlways exits with the same status as
617a7434feSchristos.Ar command
627a7434feSchristoseven if it times out.
63*f2d4de93Skre.It Fl f , Fl Fl foreground
647a7434feSchristosDo not propagate timeout to the
657a7434feSchristos.Ar command
667a7434feSchristoschildren.
6777ebce0bSwiz.It Fl s Ar sig , Fl Fl signal Ar sig
687a7434feSchristosSpecify the signal to send on timeout.
697a7434feSchristosBy default,
70a76b73c7Sdholland.Dv SIGTERM
717a7434feSchristosis sent.
7277ebce0bSwiz.It Fl k Ar time , Fl Fl kill-after Ar time
737a7434feSchristosSend a second kill signal if
747a7434feSchristos.Ar command
757a7434feSchristosis still running after
767a7434feSchristos.Ar time
777a7434feSchristosafter the first signal was sent.
787a7434feSchristos.El
797a7434feSchristos.Sh DURATION FORMAT
807a7434feSchristos.Ar duration
817a7434feSchristosand
827a7434feSchristos.Ar time
837a7434feSchristoscan be integer or decimal numbers.
847a7434feSchristosValues without unit symbols are interpreted as seconds.
857a7434feSchristos.Pp
867a7434feSchristosSupported unit symbols are:
877a7434feSchristos.Bl -tag -width indent -compact
887a7434feSchristos.It s
897a7434feSchristosseconds
907a7434feSchristos.It m
917a7434feSchristosminutes
927a7434feSchristos.It h
937a7434feSchristoshours
947a7434feSchristos.It d
957a7434feSchristosdays
967a7434feSchristos.El
977a7434feSchristos.Sh EXIT STATUS
987a7434feSchristosIf the timeout was not reached, the exit status of
997a7434feSchristos.Ar command
1007a7434feSchristosis returned.
1017a7434feSchristos.Pp
1027a7434feSchristosIf the timeout was reached and
10377ebce0bSwiz.Fl Fl preserve-status
1047a7434feSchristosis set, the exit status of
1057a7434feSchristos.Ar command
1067a7434feSchristosis returned.
1077a7434feSchristosIf
10877ebce0bSwiz.Fl Fl preserve-status
1097a7434feSchristosis not set, an exit status of 124 is returned.
1107a7434feSchristos.Pp
1117a7434feSchristosIf
1127a7434feSchristos.Ar command
1137a7434feSchristosexits after receiving a signal, the exit status returned is the signal number plus 128.
1147a7434feSchristos.Sh SEE ALSO
1157a7434feSchristos.Xr kill 1 ,
1167a7434feSchristos.Xr signal 3
1173f7fdb96Schristos.Sh HISTORY
1183f7fdb96SchristosA
1193f7fdb96Schristos.Nm
1203f7fdb96Schristosutility appeared in a development branch of
1213f7fdb96Schristos.Fx 11
1223f7fdb96Schristosand was imported into
1233f7fdb96Schristos.Nx 7 .
1243f7fdb96SchristosThe
1253f7fdb96Schristos.Fx
1263f7fdb96Schristoswork is compatible with GNU
12777ebce0bSwiz.Nm
12877ebce0bSwizby
12977ebce0bSwiz.An Padraig Brady ,
13077ebce0bSwizfrom GNU Coreutils 8.21.
13177ebce0bSwizThe
13277ebce0bSwiz.Nm
1333f7fdb96Schristosutility first appeared in GNU Coreutils 7.0.
134