Killing a process when some other process is finished
2
votes
1
answer
650
views
Given
a | b
, i'd like to kill b
when a
is finished. b
is an interactive process, which doesn't terminates when a
is finished (fzf
in my case), and the whole a | b
is executed in a $()
subshell.
So far what i come up with was
echo $({ sleep 5 & a=$!; { wait $a; kill $b; } } | { fzf & b=$!; })
sleep
represents a
, and fzf
represents b
, the result in the example is used by echo
, but in my case, it'd be an argument for ssh
. It seems, that $b
is not the PID of fzf
, it's empty. As far as i understand, this shouldn't be the case, since i've used {}
, and not ()
, so it's not executed in a subshell.
Asked by lennoff
(121 rep)
Dec 10, 2018, 10:14 PM
Last activity: Oct 6, 2024, 09:59 AM
Last activity: Oct 6, 2024, 09:59 AM