I frequently VNC into a server where we run many concurrent computationally intensive matlab processes. Sometimes, one of my processes misbehave, which I can see from top, but I have a hard time figuring out which VNC session it's running on, or more specifically, which display it's running on.
Suppose I see that PID 8536 looks like a resource hog, and I want to investigate. Because it's a matlab session, I know there is likely an IDE open somewhere, and I want to check to see if anything important is happening before I kill it.
We've solved this somewhat awkwardly in the past by identifying which PTY 8536 was launched from, then looking at a process tree to figure out things launched in that context, scrolling up, and seeing the VNC initialization.
Seems like there must be a better way to go PID -> X Display (or VNC Session).