From dc52bfff1736817a5c375ba100551caae7173b6c Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Mon, 3 Aug 2020 18:54:15 +0100 Subject: [PATCH] launcher: implement Terminate() This allows IPC clients to terminate the launcher. Signed-off-by: Simon McVittie <smcv@collabora.com> --- src/com.steampowered.PressureVessel.Launcher1.xml | 9 +++++++++ src/launcher.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/com.steampowered.PressureVessel.Launcher1.xml b/src/com.steampowered.PressureVessel.Launcher1.xml index ee47e85ce..8313f5787 100644 --- a/src/com.steampowered.PressureVessel.Launcher1.xml +++ b/src/com.steampowered.PressureVessel.Launcher1.xml @@ -138,6 +138,15 @@ <arg type='u' name='wait_status'/> </signal> + <!-- + Terminate: + + Stop listening for Launch and SendSignal requests, terminate + child processes if any, and shut down gracefully. + --> + <method name="Terminate"> + </method> + </interface> </node> diff --git a/src/launcher.c b/src/launcher.c index 522797cba..2a98a3ebc 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -418,6 +418,16 @@ handle_send_signal (PvLauncher1 *object, return TRUE; } +static gboolean +handle_terminate (PvLauncher1 *object, + GDBusMethodInvocation *invocation) +{ + terminate_children (SIGTERM); + pv_launcher1_complete_terminate (object, invocation); + unref_skeleton_in_timeout (); + return TRUE; /* handled */ +} + static void name_owner_changed (GDBusConnection *connection, const gchar *sender_name, @@ -480,6 +490,8 @@ export_launcher (GDBusConnection *connection, G_CALLBACK (handle_launch), NULL); g_signal_connect (launcher, "handle-send-signal", G_CALLBACK (handle_send_signal), NULL); + g_signal_connect (launcher, "handle-terminate", + G_CALLBACK (handle_terminate), NULL); } if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (launcher), -- GitLab