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. https://bugzilla.gnome.org/show_bug.cgi?id=772613
This commit is contained in:
parent
1fab6e69b7
commit
e9944350d3
@ -185,6 +185,22 @@ meta_window_delete (MetaWindow *window,
|
||||
void
|
||||
meta_window_kill (MetaWindow *window)
|
||||
{
|
||||
pid_t pid = meta_window_get_client_pid (window);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
META_WINDOW_GET_CLASS (window)->kill (window);
|
||||
}
|
||||
|
||||
|
@ -106,24 +106,6 @@ 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,
|
||||
|
@ -704,23 +704,6 @@ meta_window_x11_delete (MetaWindow *window,
|
||||
static void
|
||||
meta_window_x11_kill (MetaWindow *window)
|
||||
{
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Killing %s brutally\n",
|
||||
window->desc);
|
||||
|
||||
if (!meta_window_is_remote (window) &&
|
||||
window->net_wm_pid > 0)
|
||||
{
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Killing %s with kill()\n",
|
||||
window->desc);
|
||||
|
||||
if (kill (window->net_wm_pid, 9) < 0)
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Failed to signal %s: %s\n",
|
||||
window->desc, strerror (errno));
|
||||
}
|
||||
|
||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||
"Disconnecting %s with XKillClient()\n",
|
||||
window->desc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user