From 52738eedcf75d9c8da2ad13a93b855083002839e Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Tue, 15 Mar 2022 15:47:46 +0000 Subject: [PATCH] implement Kill action this action sends SIGTERM to a client's process --- src/action.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/action.c b/src/action.c index b6440a5a..c1dacb6e 100644 --- a/src/action.c +++ b/src/action.c @@ -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;