implement Kill action

this action sends SIGTERM to a client's process
This commit is contained in:
bi4k8 2022-03-15 15:47:46 +00:00 committed by Johan Malm
parent 39bea30cd5
commit 52738eedcf

View file

@ -37,6 +37,7 @@ enum action_type {
ACTION_TYPE_INVALID = 0,
ACTION_TYPE_NONE,
ACTION_TYPE_CLOSE,
ACTION_TYPE_KILL,
ACTION_TYPE_DEBUG,
ACTION_TYPE_EXECUTE,
ACTION_TYPE_EXIT,
@ -63,6 +64,7 @@ const char *action_names[] = {
"INVALID",
"None",
"Close",
"Kill",
"Debug",
"Execute",
"Exit",
@ -244,6 +246,17 @@ actions_run(struct view *activator, struct server *server,
view_close(view);
}
break;
case ACTION_TYPE_KILL:
if (view && view->surface) {
/* Send SIGTERM to the process associated with the surface */
pid_t pid = -1;
struct wl_client *client = view->surface->resource->client;
wl_client_get_credentials(client, &pid, NULL, NULL);
if (pid != -1) {
kill(pid, SIGTERM);
}
}
break;
case ACTION_TYPE_DEBUG:
debug_dump_scene(server);
break;