After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772613 - Add meta_window_get_client_pid() method
Add meta_window_get_client_pid() method
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks: 772614
 
 
Reported: 2016-10-08 16:23 UTC by Florian Müllner
Modified: 2016-10-10 22:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window: Add get_client_pid() method (6.52 KB, patch)
2016-10-08 16:23 UTC, Florian Müllner
committed Details | Review
delete: Share some code between X11 and wayland (3.14 KB, patch)
2016-10-08 16:23 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2016-10-08 16:23:36 UTC
Having a way to identify the PID of the process that owns a window without relying on the application is part of making window matching reliable for Flatpak apps. I went with a separate method for now, though another option would be to extend the existing meta_window_get_pid() (that is, only fall back to _NET_WM_PID if the attempt to query the X server fails).
Comment 1 Florian Müllner 2016-10-08 16:23:43 UTC
Created attachment 337239 [details] [review]
window: Add get_client_pid() method

It is often useful to identify the client process that created
a particular window, however the existing meta_window_get_pid()
method relies on _NET_WM_PID, which is only available on X11 and
depends on applications to set it correctly (which may not even
be possible when the app runs in its own PID namespace as Flatpak
apps do). So add a get_client_pid() method that uses windowing
system facilities to resolve the PID associated with a particular
window.
Comment 2 Florian Müllner 2016-10-08 16:23:49 UTC
Created attachment 337240 [details] [review]
delete: Share some code between X11 and wayland

In order to kill a window, on both X11 and wayland we first try to
kill(3) the corresponding process, so we can add the newly added
get_client_pid() method to share that code.
Comment 3 Rui Matos 2016-10-10 20:09:16 UTC
Review of attachment 337239 [details] [review]:

looks fine

::: configure.ac
@@ +86,3 @@
    x11-xcb
    xcb-randr
+   xcb-res

hopefully this is widely deployed, the X server implementation seems to be ~6 years old

::: src/x11/window-x11.c
@@ +1497,3 @@
+
+  cookie = xcb_res_query_client_ids (xcb, 1, &spec);
+  reply = xcb_res_query_client_ids_reply (xcb, cookie, NULL);

round trip :-/ I guess it doesn't matter too much in practice
Comment 4 Rui Matos 2016-10-10 20:12:23 UTC
Review of attachment 337240 [details] [review]:

++

::: src/x11/window-x11.c
@@ -706,3 @@
 {
   meta_topic (META_DEBUG_WINDOW_OPS,
-              "Killing %s brutally\n",

y u hate fun debug messages?!!!1!!one
Comment 5 Florian Müllner 2016-10-10 22:53:47 UTC
Attachment 337239 [details] pushed as 1fab6e6 - window: Add get_client_pid() method
Attachment 337240 [details] pushed as e994435 - delete: Share some code between X11 and wayland