Code first
echo $$ - $BASHPID
find . | while read -r file; do
echo $$ - $BASHPID: ${file}
done
The problem is the code in while<
Just use process substitution:
echo "$$ - $BASHPID"
while read -r file; do
echo "$$ - $BASHPID: ${file}" #better to quote!
done < <(find .)
# -----^^^^^^^^^
From the given link:
Process substitution is a form of redirection where the input or output of a process (some sequence of commands) appear as a temporary file.