We can simply allow an access to backend process id thru psql variable. I propose the name "BACKEND_PID". The advantages of usage are simple accessibility by command \set, and less typing then using function pg_backend_pid, because psql variables are supported by tab complete routine. Implementation is very simple, because we can use the function PQbackendPID.
Comments, notes?
Regards
Pavel
Interesting, and probably useful.
It needs a corresponding line in UnsyncVariables():
SetVariable(pset.vars, "BACKEND_PID", NULL);
That will set the variable back to null when the connection goes away.