From e8f0d76da75b6b66d5499faab843a10c88ca3e4a Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 14 Mar 2022 20:39:35 +0000 Subject: [PATCH] Do not leak child processes when cancelling See https://github.com/fwupd/fwupd/pull/4372 --- libfwupdplugin/fu-common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libfwupdplugin/fu-common.c b/libfwupdplugin/fu-common.c index e39d66e3b..bcc422211 100644 --- a/libfwupdplugin/fu-common.c +++ b/libfwupdplugin/fu-common.c @@ -838,10 +838,16 @@ fu_common_spawn_sync(const gchar *const *argv, fu_common_spawn_create_pollable_source(helper); g_main_loop_run(helper->loop); g_cancellable_disconnect(cancellable, cancellable_id); +#endif + if (!g_subprocess_wait_check(subprocess, cancellable, error)) + return FALSE; +#ifndef _WIN32 if (g_cancellable_set_error_if_cancelled(helper->cancellable, error)) return FALSE; #endif - return g_subprocess_wait_check(subprocess, cancellable, error); + + /* success */ + return TRUE; } /**