To be clear with the title question, I understand why the former dies. I don't understand why the latter doesn't, just for adding a
| cat to the loop body.
Also maybe related,
while true; do echo y; done
dies immediately when I do
^C, but killing
while true; do echo y | cat; done
often takes hitting
^C more than once. Sometimes once works, other times 2 or 3 times works, then there are times where I need to hold
^C for a while for it to die.
Both behaviors happen in both bash and zsh, although the
^C one seems to be rarer with bash.
For both behaviors, this isn't limited to adding the pipe to
| tee, etc. also cause them. Even
echo y | true causes it. It seems to be the presence of any pipe in the loop body.
Why does the presence of a pipe in a loop body change the loop's response to signals?