On Wed, 2004-03-24 at 03:52, dave giffin wrote:
> I need to be able to tell which process a given window
> was created by. (Window ID=>Process ID)

On the server side, in os/access.c, is a function LocalClientCred() that
you can use to get the UID and GID of a local client.  This function
could be extended to return the PID as well since the structure returned
by the SO_PEERCRED sockopt has the PID in it.  Take a look at it;
there's already a bunch of _XTrans stuff dealing with this sort of
thing.

--Eamon

> 
> Apparently, X servers don't know which process a
> client is, they just get a socket (b/c of X's network
> transparency).
> 
> It has been suggested that I could run a program like
> netstat on the client machine(which in my case is the
> same machine running the server) to get a list of
> which sockets belong to which processes.
> 
> Then, I need to get the ID of the foreign socket
> (socket ID on client end) from which a window was
> created.
> 
> What would work well is if the socket ID and the
> client/window ID could be written to STDOUT or STDIN
> when the window is created. Then I can have a script
> read the server's STDOUT or STDIN and compare it to
> the list of socket IDs and process IDs from netstat on
> the client machine (which for my purposes is on the
> same machine as the server).
> 
> MY PROBLEM: I don't know how to get XFree86 to write
> the socket ID and client ID when a window is created!
> 
> Today, I was looking at the XFree86(4.3.0) source code
> for the first time and trying some different hacks to
> get the info I wanted to print. 
> 
> In xc/programs/Xserver/dix/dispatch.c, I found
> ProcCreateWindow and the ClientPtr structure. I was
> able to get X to print client->index and
> client->OsPrivate->fd when a new window was created.
> 
> Which is what I want, except that the client index
> that is printed is always 2 and the socket ID is
> always 13. 13 is the ID of the socket that X listens
> on and I think 2 is the server client?
> 
> What am I doing wrong?
> 
> How can I print the Window ID and foreign/from socket
> ID of a client when a window is created?
> 
> 
> :) thanx
> 
> PS: I'm thinking of making a sourceforge project to
> publish the XFree86 modification and some associated
> scripts so that others will be able to see which
> process created which window. How does the project
> name XTracer sound?
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance Tax Center - File online. File on time.
> http://taxes.yahoo.com/filing.html
> _______________________________________________
> Devel mailing list
> [EMAIL PROTECTED]
> http://XFree86.Org/mailman/listinfo/devel
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel

Reply via email to