fix windows kill on subprocess/process

This commit is contained in:
cirospaciari
2024-03-04 10:17:51 -03:00
parent 3edb6329d9
commit c57afe9bfe
3 changed files with 8 additions and 2 deletions

View File

@@ -494,7 +494,10 @@ pub const Process = struct {
switch (this.poller) {
.uv => |*handle| {
if (handle.kill(signal).toError(.kill)) |err| {
return .{ .err = err };
// if the process was already killed don't throw
if (err.errno != @intFromEnum(bun.C.E.SRCH)) {
return .{ .err = err };
}
}
return .{

View File

@@ -575,6 +575,7 @@ pub const Subprocess = struct {
switch (this.tryKill(sig)) {
.result => {},
.err => |err| {
// EINVAL or ENOSYS means the signal is not supported in the current platform (most likely unsupported on windows)
globalThis.throwValue(err.toJSC(globalThis));
return .zero;
},

View File

@@ -975,7 +975,9 @@ pub const SignalCode = enum(u8) {
SIGSYS = 31,
_,
pub const default = if (Environment.isWindows) 1 else @intFromEnum(SignalCode.SIGTERM);
// The `subprocess.kill()` method sends a signal to the child process. If no
// argument is given, the process will be sent the 'SIGTERM' signal.
pub const default = @intFromEnum(SignalCode.SIGTERM);
pub const Map = ComptimeEnumMap(SignalCode);
pub fn name(value: SignalCode) ?[]const u8 {
if (@intFromEnum(value) <= @intFromEnum(SignalCode.SIGSYS)) {