Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

up vote 1 down vote accepted

In the process filesystem there is a file called environ that should contain the environment variables that are set for any given PID, including the variable VNCDESKTOP which should include the screen number of that processes parent VNC session.

This should display the information:

awk -v 'RS=\0' -F = '$1=="VNCDESKTOP" {print $2}' /proc/$PID/environ
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.