One easy way is info inferior . Here I am debugging gdb with myself, and this command shows the PID debuggee:
(top-gdb) info inferior Num Description Executable * 1 process 14068 /home/tromey/gdb/build/gdb/gdb
You can also just call the regular C function:
(top-gdb) print getpid() $3 = 14068
Tom tromey
source share