It's better to use $(exec sh -c 'echo $PPID') rather than tricks shown in answer by John1024 (those tricks not work witn modern shells at present time, when I writing my reply).
See this question:
https://unix.stackexchange.com/questions/484442/how-can-i-get-the-pid-of-a-subshell