How to get the running process’ pid in Bash?
In Bash, you can get the process ID from the variable $$.
Note that in a subshell invoked by ‘(…)‘, $$
is actually the parent process’ pid.
In Bash 4, you can also use $BASHPID
to get the process pid.