diff options
-rw-r--r-- | ext/node/polyfills/process.ts | 4 | ||||
-rw-r--r-- | tests/unit_node/process_test.ts | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index d9c953514..9c73f5a51 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -259,6 +259,10 @@ memoryUsage.rss = function (): number { // Returns a negative error code than can be recognized by errnoException function _kill(pid: number, sig: number): number { + // signal 0 does not exist in constants.os.signals, thats why it have to be handled explicitly + if (sig === 0) { + return op_node_process_kill(pid, 0); + } const maybeSignal = Object.entries(constants.os.signals).find(( [_, numericCode], ) => numericCode === sig); diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts index 491a70bfc..0eadb0a16 100644 --- a/tests/unit_node/process_test.ts +++ b/tests/unit_node/process_test.ts @@ -243,6 +243,11 @@ Deno.test( args: ["eval", "setTimeout(() => {}, 10000)"], }).spawn(); + // kill with signal 0 should keep the process alive in linux (true means no error happened) + // windows ignore signals + if (Deno.build.os !== "windows") { + assertEquals(process.kill(p.pid, 0), true); + } process.kill(p.pid); await p.status; }, |