In my script I am starting multiple background processes and one of them is
(
tail -qF -n 0 logs/nginx/*.log
) &
processes[logs]=$!
for process in "${!processes[@]}"; do
wait "${processes[$process]}"
done
When sending SIGTERM signal all processes ends only tail is left running. After some testing I came up to the solution to send tail to background and its working.
(
tail -qF -n 0 logs/nginx/*.log &
) &
processes[logs]=$!
for process in "${!processes[@]}"; do
wait "${processes[$process]}"
done
Can someone explain to me what is happening when I send tail to background in subshell so it ends when SIGTERM arrives?