Subshells are interesting beasts.
#!/usr/bin/env bash
echo Parent: $$ $BASHPID
(
echo Child: $$ $BASHPID
(
echo Grandchild: $$ $BASHPID
)
)
Note that /bin/bash
on macOS is old and does not support $BASHPID
, so it does not support differentiating subshell processes.