From 42bafe9d599799e47cd11a421282bfb4a40a6af6 Mon Sep 17 00:00:00 2001 From: Leorize Date: Sat, 7 Jun 2025 12:44:21 -0500 Subject: [PATCH] flatpak: detach process tracking thread after spawn This makes sure the underlying thread implementation know to free resources the moment the thread is no longer necessary, preventing leaks from not manually collecting the thread. --- src/os/flatpak.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/os/flatpak.zig b/src/os/flatpak.zig index 7b92a8ba9..eaff529b0 100644 --- a/src/os/flatpak.zig +++ b/src/os/flatpak.zig @@ -112,6 +112,8 @@ pub const FlatpakHostCommand = struct { pub fn spawn(self: *FlatpakHostCommand, alloc: Allocator) !u32 { const thread = try std.Thread.spawn(.{}, threadMain, .{ self, alloc }); thread.setName("flatpak-host-command") catch {}; + // We don't track this thread, it will terminate on its own on command exit + thread.detach(); // Wait for the process to start or error. self.state_mutex.lock();