The following issue has been SUBMITTED. ====================================================================== https://austingroupbugs.net/view.php?id=1586 ====================================================================== Reported By: steffen Assigned To: ====================================================================== Project: 1003.1(2016/18)/Issue7+TC2 Issue ID: 1586 Category: Shell and Utilities Type: Enhancement Request Severity: Editorial Priority: normal Status: New Name: steffen Organization: User Reference: Section: Vol. 3: Shell and Utilities Page Number: Line Number: (Line or range of lines) Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2022-05-14 22:07 UTC Last Modified: 2022-05-14 22:07 UTC ====================================================================== Summary: timeout - new utility: run a command with a time limit Description: As of today it is very complicated to reliably run a program from within a sh(1)ell with a timeout, a sh(1)ell can only hardly kill a child after a timeout without introducing a race, as shown in issue #1585.
All modern operating systems (to my knowledge) therefore ship a timeout(1) command for some time, which can be used to reliably run a program with a timeout set. Desired Action: Add the timeout utility. Here is the current manual page as present on OpenBSD, taken from FreeBSD, under 2-clause BSD license: NAME timeout – run a command with a time limit SYNOPSIS timeout [-k time] [-s sig] [--foreground] [--preserve-status] duration command [args] DESCRIPTION The timeout utility executes command, with any args, and kills it if it is still running after the specified duration. If duration is 0, the timeout is disabled. The options are as follows: -k time Send a second signal, SIGKILL, if the command is still running time after the first signal was sent. SIGTERM. --foreground Do not propagate the timeout signal to children processes. --preserve-status Always exit with the same status as command, even if the timeout was reached. DURATION FORMAT duration and time may contain a decimal fraction. The value defaults to seconds unless a unit suffix is given. The supported unit suffixes are: s seconds m minutes h hours d days EXIT STATUS If the timeout was not reached or --preserve-status was set, the exit status of command is returned. If the timeout was reached and --preserve-status was not set, an exit status of 124 is returned. If command exited after receiving a signal, the exit status returned is the signal number plus 128. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2022-05-14 22:07 steffen New Issue 2022-05-14 22:07 steffen Name => steffen 2022-05-14 22:07 steffen Section => Vol. 3: Shell and Utilities 2022-05-14 22:07 steffen Line Number => (Line or range of lines) ======================================================================