[mutter/gnome-3-20] wayland: Implement force-quit using kill()



commit e75d9a5237e325a1419c01c2cd294f2fbeac2fc4
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Fri Jun 10 09:21:21 2016 +0200

    wayland: Implement force-quit using kill()
    
    The X11 backend uses EWMH's _NET_WM_PID to get the PID of an offending
    client and kill its PID to force the client to terminate.
    
    The Wayland backend is using a Wayland protocol error, but if the client
    is hung, that will not be sufficient to kill the client.
    
    Retrieve the client PID under Wayland using the Wayland client API
    wl_client_get_credentials() and kill() the client the same way the X11
    backend does.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767464

 src/wayland/meta-window-wayland.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 817e498..b360f91 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -27,6 +27,8 @@
 #include "meta-window-wayland.h"
 
 #include <meta/errors.h>
+#include <errno.h>
+#include <string.h> /* for strerror () */
 #include "window-private.h"
 #include "boxes-private.h"
 #include "stack-tracker.h"
@@ -109,6 +111,24 @@ meta_window_wayland_kill (MetaWindow *window)
 {
   MetaWaylandSurface *surface = window->surface;
   struct wl_resource *resource = surface->resource;
+  pid_t pid;
+  uid_t uid;
+  gid_t gid;
+
+  wl_client_get_credentials (wl_resource_get_client (resource), &pid, &uid, &gid);
+  if (pid > 0)
+    {
+      meta_topic (META_DEBUG_WINDOW_OPS,
+                  "Killing %s with kill()\n",
+                  window->desc);
+
+      if (kill (pid, 9) == 0)
+        return;
+
+      meta_topic (META_DEBUG_WINDOW_OPS,
+                  "Failed to signal %s: %s\n",
+                  window->desc, strerror (errno));
+    }
 
   /* Send the client an unrecoverable error to kill the client. */
   wl_resource_post_error (resource,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]