Subject: Re: bug#70219: Bug/Issue with timeout and signals

From: "Branden R. Williams" <[email-masked]>
Date: Fri, 5 Apr 2024 17:14:54 -0500

That’s not an accurate representation of what the command actually does. The argument after -k MUST be the kill signal code, without the code the command fails. The manpage and help document agree with what you are saying but the execution of the program fails. 

That functionality is not represented in the manpage or --help. If you used -k 10 10s it would send a SIGTERM vs SIGKILL. The point is that the argument immediately after the -k or --kill-after= is the kill signal code, not the duration. The manpage and help file suggest that it should be the duration.

That’s why I am suggesting using a default SIGTERM if the -k or --kill-after= is passed so that the duration is the actual argument that follows. If you wanted to alter the signal, that’s where the -s flag comes in.

> On Apr 5, 2024, at 4:59 PM, Chris Elvidge <[email-masked]> wrote:
> 
> 
> 
> On 05/04/2024 at 16:19, Branden R. Williams via GNU coreutils Bug Reports wrote:
>> I was integrating the timeout command into a shell script and realized the manpage & the --help docs do not accurately describe how the tool works. In addition, there appears to be a bug related to arguments passed. I am running version 9.1.
>> According to the help screen, this command should work:
>> 	timeout -k 10s ping https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com&d=DwICaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=1o61i4CUhS9OzzVMraHh20b966TBpqSO4_0GGRNaLWA&m=aJDfsufl90pc4lE-vjk1Oo94O1RIrEP39t_G7X5-pvl_5ZXtR-2jcnl0a5OxJgGu&s=VjTsmLfaTKmXMJL0S6OXC7PHTK-rxRwmG7skx4FheqY&e= <https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_&d=DwICaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=1o61i4CUhS9OzzVMraHh20b966TBpqSO4_0GGRNaLWA&m=aJDfsufl90pc4lE-vjk1Oo94O1RIrEP39t_G7X5-pvl_5ZXtR-2jcnl0a5OxJgGu&s=i2LYw6g0va2Fbz-arA9sTJOn7_G1uY3hN2Pf5pLautc&e=>
>> It fails, however, because the next argument after invoking -k is the kill signal you want to send. The command (to send a SIGKILL) must be:
> 
> As I understand it, the argument after -k (or --kill-after=) is the time to wait and send the kill signal if the timeout fails.
> So this line:
> 
>> 	timeout -k 9 10s ping https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com&d=DwICaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=1o61i4CUhS9OzzVMraHh20b966TBpqSO4_0GGRNaLWA&m=aJDfsufl90pc4lE-vjk1Oo94O1RIrEP39t_G7X5-pvl_5ZXtR-2jcnl0a5OxJgGu&s=VjTsmLfaTKmXMJL0S6OXC7PHTK-rxRwmG7skx4FheqY&e= <https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_&d=DwICaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=1o61i4CUhS9OzzVMraHh20b966TBpqSO4_0GGRNaLWA&m=aJDfsufl90pc4lE-vjk1Oo94O1RIrEP39t_G7X5-pvl_5ZXtR-2jcnl0a5OxJgGu&s=i2LYw6g0va2Fbz-arA9sTJOn7_G1uY3hN2Pf5pLautc&e=>
> 
> sends a kill signal 9 seconds after the timeout, if the timeout hasn't worked.
> 
> The -s option is to change the signal sent (as below).
> 
>> I believe the kill after functionality and docs should be modified to send a default signal of SIGTERM without an additional argument so the first iteration above would work. Then you could explain that if you wanted to send a DIFFERENT signal, use the -s flag that is there to pass one. But according to the docs, the first command SHOULD work. Even using the --kill-after= syntax passes in the kill signal into that argument, not the actual time.
>> Thank you for your consideration and for maintaining such a critical set of tools!
>> Regards,
>> B
> 
> 
> -- 
> 
> Chris Elvidge
>