How to get the running process’ pid in Bash?

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.

Answered by dtivl.

Leave a Reply

Your email address will not be published. Required fields are marked *