From b46da660563b175722937d9f29d45029bd6a0a74 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Tue, 4 Jan 2022 21:55:06 +0100 Subject: fix(signals): prevent panic when listening to forbidden signals (#13273) --- cli/tests/unit/signal_test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/signal_test.ts b/cli/tests/unit/signal_test.ts index 31562c99a..b67dc9668 100644 --- a/cli/tests/unit/signal_test.ts +++ b/cli/tests/unit/signal_test.ts @@ -203,3 +203,37 @@ Deno.test( }); }, ); + +Deno.test( + { + ignore: Deno.build.os === "windows", + permissions: { run: true }, + }, + function signalForbiddenSignalTest() { + assertThrows( + () => Deno.addSignalListener("SIGKILL", () => {}), + TypeError, + "Binding to signal 'SIGKILL' is not allowed", + ); + assertThrows( + () => Deno.addSignalListener("SIGSTOP", () => {}), + TypeError, + "Binding to signal 'SIGSTOP' is not allowed", + ); + assertThrows( + () => Deno.addSignalListener("SIGILL", () => {}), + TypeError, + "Binding to signal 'SIGILL' is not allowed", + ); + assertThrows( + () => Deno.addSignalListener("SIGFPE", () => {}), + TypeError, + "Binding to signal 'SIGFPE' is not allowed", + ); + assertThrows( + () => Deno.addSignalListener("SIGSEGV", () => {}), + TypeError, + "Binding to signal 'SIGSEGV' is not allowed", + ); + }, +); -- cgit v1.2.3