mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix: handle signal 0 in process.kill (#23473)
the last commit had a regression, where it removed this branch, I haven't tested the code but I think it should work --------- Signed-off-by: Bedis Nbiba <bedisnbiba@gmail.com>
This commit is contained in:
parent
9e890399fc
commit
927cbb5ecd
2 changed files with 9 additions and 0 deletions
|
@ -259,6 +259,10 @@ memoryUsage.rss = function (): number {
|
||||||
|
|
||||||
// Returns a negative error code than can be recognized by errnoException
|
// Returns a negative error code than can be recognized by errnoException
|
||||||
function _kill(pid: number, sig: number): number {
|
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((
|
const maybeSignal = Object.entries(constants.os.signals).find((
|
||||||
[_, numericCode],
|
[_, numericCode],
|
||||||
) => numericCode === sig);
|
) => numericCode === sig);
|
||||||
|
|
|
@ -243,6 +243,11 @@ Deno.test(
|
||||||
args: ["eval", "setTimeout(() => {}, 10000)"],
|
args: ["eval", "setTimeout(() => {}, 10000)"],
|
||||||
}).spawn();
|
}).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);
|
process.kill(p.pid);
|
||||||
await p.status;
|
await p.status;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue