Bug 10571

Summary: busybox timeout options is not compatible with coreutils timeout
Product: Busybox Reporter: alex hauras <d77190>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs, calestyo, d77190
Priority: P5    
Version: 1.27.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description alex hauras 2017-12-10 04:59:41 UTC
Here is the problem:
# ./busybox timeout --help
BusyBox v1.27.2 (2017-12-10 11:45:39 +07) multi-call binary.

Usage: timeout [-t SECS] [-s SIG] PROG ARGS

Runs PROG. Sends SIG to it if it is not gone in SECS seconds.
Defaults: SECS: 10, SIG: TERM.

# LANG=C timeout --help
Usage: timeout [OPTION] DURATION COMMAND [ARG]...
  or:  timeout [OPTION]
Start COMMAND, and kill it if still running after DURATION.


I think that better way is to use first arg as timeout if -t option is not specified (and ignore -k option that missing in busybox timeout).
Comment 1 Christoph Anton Mitterer 2021-10-12 02:46:37 UTC
It's more than just the missing options.

coreutils timeout seems to require --foreground, when the command wants to read from the tty,... busybox' doesn't (it's able to do so with no action).


Should anyone ever do something in this area than please note that coreutils' exit statuses and options are quite special in some cases:

--kill-after=0
means actually: send no KILL signal (after the initial signal, which still might be KILL) at all ... and not send it immediately after the initial signal
(see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51128)


with --foreground, at least as of current coreutils, the exit status is still 124 when a KILL was sent, even though without --forground, 137 would be used with KILL.
(see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51135)
Comment 2 Christoph Anton Mitterer 2021-10-12 14:09:25 UTC
An update on the thing with coreutil's 124 vs. 137 exit status when KILL is sent while --foregrund is used.

Seem I was able to convince upstream to change the behaviour:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51135#25

So future version will apparently use 137 *whenever* KILL is sent.
Comment 3 Denys Vlasenko 2021-12-12 02:08:25 UTC
DURATION discrepancy has been fixed:

commit c9720a761e88e83265b4d75808533cdfbc66075b
Date:   Fri Aug 3 18:27:00 2018 +0200

    timeout: fix arguments to match coreutils

    Was: timeout [-t SECS] [-s SIG] PROG ARGS
    Is:  timeout [-s SIG] SECS PROG ARGS