home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Newsgroups: comp.windows.x
- Subject: Re: Mapping A Window To A Process
- Message-ID: <1992Nov7.105306.20140@thunder.mcrcim.mcgill.edu>
- Date: 7 Nov 92 10:53:06 GMT
- References: <Bx7oBI.5IG@cs.columbia.edu>
- Organization: McGill Research Centre for Intelligent Machines
- Lines: 48
-
- In article <Bx7oBI.5IG@cs.columbia.edu>, haupt@cs.columbia.edu (Marcus E. Haupt) writes:
-
- > I would like to know if anyone has come across a method to findt the
- > UNIX pid of a process given only a window (Xlib data struct pointer)
- > that is known to have been created by that process.
-
- At the Xlib level, a window (data type Window) is not a data structure
- pointer, or at least usually isn't. In the MIT sample implementation,
- and presumably most other implementations, the Window datatype is just
- a 32-bit unsigned integer.
-
- Given a window ID (the 32-bit value) and a server (window IDs are
- meaningless without a server to refer them to), there is little you can
- do in most cases. It would be possible, by hacking on the server, to
- find out everything possible about the connection. However, this may
- not be much. For a TCP connection, all you can get is the address and
- port number of the remote end; for a UNIX-domain connection, if they
- exist, not even that much can be determined.
-
- In any case, there may not be any "UNIX pid"; the client process may
- not be running on a UNIX machine. It could be VMS, for example, or it
- could be a Mac running Planet X (I think that's the name), or it could
- be a DOS box running whatever it's called that does the analogous thing
- for DOS....
-
- > Or, conversely, given a pid known to have initiated a connection with
- > the X Server, is there any way to find out what the Window Tree for
- > that process looks like?
-
- Depends on how dirty you want to get your hands. First, we have to
- assume that the connection in question is still open. Second, we have
- to decide what to do if the process has more than one X connection
- open. Once those issues have been addressed, we have to grub around in
- the Xlib data structures inside that process (which means reading its
- address space, which involves system-dependent and usually messy and
- fragile kludges) to find (a) what server is on the other end of that
- connection and (b) what the resource ID mask and base values are. We
- then walk the window tree on the server in question, looking for window
- IDs that fit the mask and base we found....
-
- In short, it's so hard that you don't want to do it if you can help it,
- and you will have to learn a *lot* more about system-level software
- before you have much hope of making it work.
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-