avoid deadlock on exec

This commit is contained in:
Emil Lerch 2025-10-29 11:52:19 -07:00
parent 8a07e365c3
commit 362be00d07
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -48,9 +48,14 @@ const SpeechHandler = struct {
}) catch std.log.warn("Caught error writing speech data to stdout", .{});
// Execute program if specified
if (self.exec_program) |program| self.exec(event.text) catch |err| {
if (self.exec_program) |program| {
self.exec(event.text) catch |err| {
std.log.err("Failed to execute program '{s}': {}", .{ program, err });
};
self.reclaimProcessesPosix(false) catch |err| {
std.log.err("Failed to reclaim processes: {}", .{err});
};
}
}
fn exec(self: *SpeechHandler, text: []const u8) !void {
const program = self.exec_program.?; // should only be called when exec_program is not null
@ -78,7 +83,6 @@ const SpeechHandler = struct {
try process.child.?.spawn();
try process.child.?.waitForSpawn();
process.id = process.child.?.id;
try self.reclaimProcessesPosix(false);
}
fn reclaimProcessesPosix(self: *SpeechHandler, reap_all: bool) !void {