use $BASHPID
or $$
See the [manual][1] for more information, including differences between the two.
TL;DRTFM
$$
Expands to the process ID of the shell.
()
subshell, it expands to the process ID of the invoking shell, not the subshell.$BASHPID
Expands to the process ID of the current Bash process (new to bash 4).
()
subshell, it expands to the process ID of the subshell
[1]: http://www.gnu.org/software/bash/manual/bashref.html#Bash-Variables