Attaching a patch which adds support for the EWMH _NET_WM_PID on X11. This feature is critical to our environment. The patch has been tested on Debian Wheezy and is working properly. It should be at least portable to BSD.
It would be great if the maintainers could take a look at this and perhaps incorporate similar functionality into a future release.