diff options
Diffstat (limited to 'src/selection_pipe.zig')
| -rw-r--r-- | src/selection_pipe.zig | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/selection_pipe.zig b/src/selection_pipe.zig index 207d45c2..7bb919e1 100644 --- a/src/selection_pipe.zig +++ b/src/selection_pipe.zig @@ -505,12 +505,6 @@ pub fn runIn( return .{ .ok = stdout }; } -fn tokenStopped(token: u32) bool { - Running.take(); - defer Running.lock.unlock(); - return Running.isStopped(token); -} - /// Invoke the command independently for every selection. The response is all /// or nothing: one failure frees every earlier stdout and returns a failed, /// empty answer for the core to ignore. @@ -522,9 +516,13 @@ pub fn runJob(gpa: std.mem.Allocator, io: std.Io, job: *const Job) Response { for (job.inputs, 0..) |input, i| { const command = if (job.commands.len > 0) job.commands[i] else job.command; const cwd = if (job.cwds.len > 0) job.cwds[i] else job.cwd; - if (job.token != 0 and tokenStopped(job.token)) { - response.failure = .{ .kind = .signal, .index = @intCast(i) }; - break; + if (job.token != 0) { + Running.take(); + defer Running.lock.unlock(); + if (Running.isStopped(job.token)) { + response.failure = .{ .kind = .signal, .index = @intCast(i) }; + break; + } } const output = switch (runIn(gpa, io, job.shell, command, cwd, input, job.token, job.env)) { .ok => |bytes| bytes, |
