Get an X window ID

Glynn Clements glynn at gclements.plus.com
Thu May 17 18:22:56 PDT 2007


Alan Coopersmith wrote:

> > NetWM already allows you to use properties to encode the pid and
> > hostname of clients as window properties.
> 
> Should we have Xlib or xcb automatically set these so that
> we don't have to wait for every application and toolkit to
> be modified to do so?

I suggest not.

First, the client might not want to advertise this information to
other clients.

Second, it's not clear that either of these can be determined
reliably. Certainly, you can call getpid() and gethostname(), but it
it's less certain that those are the "right" values.

A host can have multiple names, some of which might not be meaningful
to the X server. The host might not even know of any hostname which is
meaningful from the X server's perspective if NAT/proxies/etc are
involved.

As for the PID, an X application can initialise the display then put
itself into the background with fork()+exit(). In that situation, it's
the child which is the actual client, and the original (parent) PID
could be re-used for a completely unrelated process.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list