bash - Linux - how does the kill -k switch work in timeout command -
i have 2 1 liners:
in first. i've expected killing sh -c "..."
command after 5 seconds exists until timeout exits (for 10 seconds)
timeout -k 5s 10s sh -c 'sleep 20s && echo "long running command visible under: ps -elf | grep sleep during whole life (10s) time of timeout command"'
in second. i've expected timeout exit return code 124 (because sh -c "..."
command still running) while command sh -c "..."
continue run (because of kill option timeout not set)
timeout 10s sh -c 'sleep 20s && echo "long running command visible under: ps -elf | grep sleep during whole life (10s) time of timeout command"'
it seems argument passed timeout runs exact time timeout command (it not killed earlier nor survive timeout) purpose of kill option then?
the option -k
send kill
signal after specified seconds if process couldn't terminated after timeout.
timeout
first sends term
signal. if -k
specified, it'll send kill
signal, following real timeout value.
for example
timeout -k 5 10 somecommand
timeout
sends term
signal after 10 seconds. if somecommand
didn't respond term
(e.g. block term
signal) timeout
sends kill
signal after 5 more seconds (i.e. @ 15th second since start of execution). signal kill
can't blocked.
Comments
Post a Comment