[mutter] wayland: Implement force-quit using kill()
- From: Olivier Fourdan <ofourdan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Implement force-quit using kill()
- Date: Fri, 10 Jun 2016 08:31:57 +0000 (UTC)
commit c72efc90cb8c221df8c865bf3738f98067a5c60e
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 07ea34a..8f51d9a 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"
@@ -102,6 +104,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]