Take the 2-minute tour ×

How to get pid from xid (X window identifier). How to get list of xids for pid?

(Assuming all applications run with DISPLAY=:0, without network transparency being in use)

Expecing something like:

  1. Dig in /proc/$pid/fd/ to track connection to X server
  2. Follow that connection, dig in /proc/pidof X/fd
  3. Dig inside X as it should know how to map connections to it to windows.
share|improve this question
In general: Not at all. The reason is that the X-Window system is/supports inherently network connection (even if you dont use it). The only viable way I could think of, is your expected internal digging - which can be different from x-server to x-server. –  flolo Apr 4 '11 at 20:04
X server is Xorg. I want solution than works in non-networked case. Isn't it obvious that it is possible for any gived system? –  Vi. Apr 4 '11 at 21:38
The "obvious" solution will involve ugly plumbing and duct tape since this isn't the way X was designed to work. –  Noufal Ibrahim Apr 5 '11 at 1:09
1. How to do it? 2. How to make it less ugly? May be there's some convenient X extension for this? –  Vi. Apr 5 '11 at 11:35
I think it's highly unlikely that there is an X extension since it's designed from the bottom up to be network transparent and not tie up a "process" to an "X resource". –  Noufal Ibrahim Apr 5 '11 at 13:53
add comment

1 Answer

You could use xprop -id <windowid> _NET_WM_PID to get the PID property of the window in question. You should know the window id of the window and not all applications set the _NET_WM_PID atom.

share|improve this answer
Few applications set pid properly, the applicatin in question (xbmc) does not. –  Vi. Apr 4 '11 at 17:28
Yup. But it is the only way I know that could work. –  Noufal Ibrahim Apr 4 '11 at 17:32
How to find it out myself? How to track connection to X server, then xid's of that connection? –  Vi. Apr 4 '11 at 19:34
You can get the id using xwininfo. I'm not sure about programmatically. –  Noufal Ibrahim Apr 5 '11 at 1:08
@Noufal Ibrahim, I think it will work only if program voluntarily declares it's PID to X server. I need solution to actually find out PID. –  Vi. Apr 5 '11 at 11:37
show 7 more comments

Your Answer


