home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / windows / x / 18859 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  2.8 KB

  1. 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
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Mapping A Window To A Process
  5. Message-ID: <1992Nov7.105306.20140@thunder.mcrcim.mcgill.edu>
  6. Date: 7 Nov 92 10:53:06 GMT
  7. References: <Bx7oBI.5IG@cs.columbia.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 48
  10.  
  11. In article <Bx7oBI.5IG@cs.columbia.edu>, haupt@cs.columbia.edu (Marcus E. Haupt) writes:
  12.  
  13. > I would like to know if anyone has come across a method to findt the
  14. > UNIX pid of a process given only a window (Xlib data struct pointer)
  15. > that is known to have been created by that process.
  16.  
  17. At the Xlib level, a window (data type Window) is not a data structure
  18. pointer, or at least usually isn't.  In the MIT sample implementation,
  19. and presumably most other implementations, the Window datatype is just
  20. a 32-bit unsigned integer.
  21.  
  22. Given a window ID (the 32-bit value) and a server (window IDs are
  23. meaningless without a server to refer them to), there is little you can
  24. do in most cases.  It would be possible, by hacking on the server, to
  25. find out everything possible about the connection.  However, this may
  26. not be much.  For a TCP connection, all you can get is the address and
  27. port number of the remote end; for a UNIX-domain connection, if they
  28. exist, not even that much can be determined.
  29.  
  30. In any case, there may not be any "UNIX pid"; the client process may
  31. not be running on a UNIX machine.  It could be VMS, for example, or it
  32. could be a Mac running Planet X (I think that's the name), or it could
  33. be a DOS box running whatever it's called that does the analogous thing
  34. for DOS....
  35.  
  36. > Or, conversely, given a pid known to have initiated a connection with
  37. > the X Server, is there any way to find out what the Window Tree for
  38. > that process looks like?
  39.  
  40. Depends on how dirty you want to get your hands.  First, we have to
  41. assume that the connection in question is still open.  Second, we have
  42. to decide what to do if the process has more than one X connection
  43. open.  Once those issues have been addressed, we have to grub around in
  44. the Xlib data structures inside that process (which means reading its
  45. address space, which involves system-dependent and usually messy and
  46. fragile kludges) to find (a) what server is on the other end of that
  47. connection and (b) what the resource ID mask and base values are.  We
  48. then walk the window tree on the server in question, looking for window
  49. IDs that fit the mask and base we found....
  50.  
  51. In short, it's so hard that you don't want to do it if you can help it,
  52. and you will have to learn a *lot* more about system-level software
  53. before you have much hope of making it work.
  54.  
  55.                     der Mouse
  56.  
  57.                 mouse@larry.mcrcim.mcgill.edu
  58.