[PATCH:xscope] Add support for process ID and names

Alan Coopersmith alan.coopersmith at oracle.com
Sun Feb 17 23:04:41 UTC 2019


On 08/ 5/15 08:17 AM, Peter Wu wrote:
> Adds the process ID and name of the other side. Useful if you have
> multiple clients. Support for OpenBSD could be added in theory since
> it has a similar "struct sockpeercred" structure (not sure about
> process name though).
> 
> After this change, the process ID and name (when available) will be
> appended between parentheses:
> 
>       0.01: Client (pid 23433 xdpyinfo) -->    4 bytes
>               ............REQUEST: ListExtensions
>       0.01:                                   332 bytes <-- X11 Server (pid 8290 Xorg)
>                                               ..............REPLY: ListExtensions
>                                                             names: (29)
> 
> Signed-off-by: Peter Wu <peter at lekensteyn.nl>
> ---
> Hi,
> 
> In presence of multiple clients, it is nice to immediately recognize the origin.
> This patch adds that for Unix domain sockets on Linux. It should also be
> possible to do this on OpenBSD (add ifdef __OpenBSD__ and use "struct
> sockpeercred cred"), but I cannot test that nor do I know how to retrieve the
> command name.
> 
> The buffer sizes are quite arbitrary (but chosen to be "large enough"). I have
> picked the FDDescriptor struct to store these properties since these are per-fd
> properties. For clarity, the functions are decomposed this way and put in a
> separate file rather than polluting fd.c.


Thanks!  And sorry for the long delay in processing.  

I've applied your patch (with the Linux support) now:

https://gitlab.freedesktop.org/xorg/app/xscope/commit/4f4c7bf594dd58db0d98c79e884c0117ded2b472

and applied a patch on top to add Solaris support:

https://gitlab.freedesktop.org/xorg/app/xscope/commit/d840ae5e5438402d752f83ddc297cf08cf2ae067

I'd imagine that adding support for other OS'es will look a lot like the
code in the Xserver's DetermineClientCmd in os/client.c and the pid portion
of the Xserver's GetLocalClientCreds in os/access.c from:

https://gitlab.freedesktop.org/xorg/xserver/tree/master/os

but will leave adding that as an exercise for those running those OS'es to
handle.

-- 
	-Alan Coopersmith-               alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - https://blogs.oracle.com/alanc


More information about the xorg-devel mailing list