coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proposed option for "timeout" -- don't wait for sub-command to exit


From: Pádraig Brady
Subject: Re: Proposed option for "timeout" -- don't wait for sub-command to exit
Date: Fri, 14 Apr 2023 21:16:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Thunderbird/109.0

On 14/04/2023 19:49, Dale R. Worley wrote:
Infrequently but repeatedly I've wanted a shell script to be able to
start a background command, wait up to a certain duration for the
command to finish, and then if it hasn't finished, the script continues,
leaving the background command to continue executing.  Other people
desire this, too, e.g.
https://unix.stackexchange.com/questions/84973/timeout-without-killing-process-in-bash
You can get this effect (without a wait loop) using "sleep NNN & wait -n
...", but you get extraneous job control output and it's awkward to
code.

Gnu "timeout" is the utility I would expect to implement this
functionality, but it does not -- timeout won't exit until the
sub-command exits no matter how you invoke it.

So I am proposing adding an option to "timeout" viz. "-n/--no-wait"
whose effect is "after the timeout is triggered and timeout sends the
specified signal(s), timeout continues without waiting for the command
to exit".  When this combined with "--signal=0", "timeout" will behave
as I desire.

Opinions?

Dale


A bit of an unusual use case.
What about the albeit slightly hacky solution presented in that SO thread?

  timeout --foreground 3 sh -c 'possibly_slow_program;exit'

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]