avoid deadlock on exec
This commit is contained in:
parent
8a07e365c3
commit
362be00d07
1 changed files with 8 additions and 4 deletions
12
src/main.zig
12
src/main.zig
|
|
@ -48,9 +48,14 @@ const SpeechHandler = struct {
|
||||||
}) catch std.log.warn("Caught error writing speech data to stdout", .{});
|
}) catch std.log.warn("Caught error writing speech data to stdout", .{});
|
||||||
|
|
||||||
// Execute program if specified
|
// Execute program if specified
|
||||||
if (self.exec_program) |program| self.exec(event.text) catch |err| {
|
if (self.exec_program) |program| {
|
||||||
std.log.err("Failed to execute program '{s}': {}", .{ program, err });
|
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 {
|
fn exec(self: *SpeechHandler, text: []const u8) !void {
|
||||||
const program = self.exec_program.?; // should only be called when exec_program is not null
|
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.?.spawn();
|
||||||
try process.child.?.waitForSpawn();
|
try process.child.?.waitForSpawn();
|
||||||
process.id = process.child.?.id;
|
process.id = process.child.?.id;
|
||||||
try self.reclaimProcessesPosix(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reclaimProcessesPosix(self: *SpeechHandler, reap_all: bool) !void {
|
fn reclaimProcessesPosix(self: *SpeechHandler, reap_all: bool) !void {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue