diff options
-rw-r--r-- | src/bun.js/api/bun/subprocess.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 2f233ed81..14febbd00 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -275,7 +275,6 @@ pub const Subprocess = struct { if (this.hasKilled()) { return .{ .result = {} }; } - this.killed = true; if (comptime Environment.isLinux) { // should this be handled differently? @@ -290,9 +289,8 @@ pub const Subprocess = struct { if (rc != 0) { const errno = std.os.linux.getErrno(rc); // if the process was already killed don't throw - if (errno == .SRCH) return .{ .result = {} }; - - return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) }; + if (errno != .SRCH) + return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) }; } } else { const err = std.c.kill(this.pid, sig); @@ -300,12 +298,12 @@ pub const Subprocess = struct { const errno = std.c.getErrno(err); // if the process was already killed don't throw - if (errno == .SRCH) return .{ .result = {} }; - - return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) }; + if (errno != .SRCH) + return .{ .err = JSC.Node.Syscall.Error.fromCode(errno, .kill) }; } } + this.killed = true; return .{ .result = {} }; } |