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.
a|bin the background and usepgrepto poll for a, thenpkillto kill b as soon as a is gone.a|bin the background, asbrequires user interaction.a|b, e.g.(sleep 20; while pgrep myProcA; do sleep 1; done; pkill myProcB ) &fzfas it can react at the time of EOF on read ofstdin; other methods would be way more complicated