PID of the Bash Process

$BASHPID expands to the process ID of the current Bash process. Subshell processes have a different ID than the parent process.

This is similar to $$, but not the same. $$ contains the process ID of the script, i.e. the parent process.

Examples

Print PID of the current process :

1
echo $BASHPID $$

Print PID of the current subshell process :

1
(echo $BASHPID $$)
BashSupport Pro 是一个 支持 $BASHPID 的 Bash 集成开发工具 – 马上试用!
© 2020–2022 Joachim Ansorg
声明
隐私政策
许可条款