Skip to content

Commit

Permalink
fix(runtime): don't equate SIGINT to SIGKILL on Windows (denoland#12356)
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus authored Oct 7, 2021
1 parent c4b995f commit 822047b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cli/tests/unit/process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ unitTest(
{ ignore: Deno.build.os !== "windows", permissions: { run: true } },
function negativePidInvalidWindows() {
assertThrows(() => {
Deno.kill(-1, "SIGINT");
Deno.kill(-1, "SIGTERM");
}, TypeError);
},
);
Expand All @@ -498,16 +498,16 @@ unitTest(
});

try {
Deno.kill(p.pid, "SIGINT");
Deno.kill(p.pid, "SIGKILL");
const status = await p.status();

assertEquals(status.success, false);
if (Deno.build.os === "windows") {
assertEquals(status.code, 1);
assertEquals(status.signal, undefined);
} else {
assertEquals(status.code, 130);
assertEquals(status.signal, 2);
assertEquals(status.code, 137);
assertEquals(status.signal, 9);
}
} finally {
p.close();
Expand Down
2 changes: 1 addition & 1 deletion runtime/ops/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub fn kill(pid: i32, signal: &str) -> Result<(), AnyError> {
use winapi::um::processthreadsapi::TerminateProcess;
use winapi::um::winnt::PROCESS_TERMINATE;

if !matches!(signal, "SIGINT" | "SIGKILL" | "SIGTERM") {
if !matches!(signal, "SIGKILL" | "SIGTERM") {
Err(type_error(format!("Invalid signal: {}", signal)))
} else if pid <= 0 {
Err(type_error("Invalid pid"))
Expand Down

0 comments on commit 822047b

Please sign in to comment.