How to get the running process' pid in Bash?

How to get the running process' pid in Bash?

asked Jun 5, 2017 by dtivl (2,500 points)

1 Answer

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 Jun 5, 2017 by dtivl (2,500 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...