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
This commit is contained in:
Olivier Fourdan 2016-06-10 09:21:21 +02:00
parent e7430a4535
commit c72efc90cb

View File

@ -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,