Why doesn't the command below exit? Rather than exit, the loop runs indefinitely.
While I discovered this behavior using a more complex setup, the simplest form of the command reduces to the following.
Does not exit:
while /usr/bin/true ; do echo "ok" | cat ; done | exit 1
There are no typos above. Each '|' is a pipe. The 'exit 1' stands in for another process that ran and exited.
I expect the "exit 1" to cause a SIGPIPE on the while loop (write on a pipe with no reader) and for the loop to break out. But, the loop continues running.
Why doesn't the command stop?