In your shell (bash in my case), you can get the pid of the last backgrounded process with the $! variable:
command &
echo $!
However, I'm interested in a compound command:
commandA | commandB &
echo $!
In this case, the value of $! seems to be the PID of commandB. What I'm looking for is the PID of commandA. Is there an easy way to get it?