From 5eaa59d96321792a5c647dc68a8d16dd4e5e3e60 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Sat, 15 Oct 2022 21:29:00 +0200 Subject: [PATCH] feat(runtime): make kill signal optional --- cli/dts/lib.deno.ns.d.ts | 8 +++++--- cli/dts/lib.deno.unstable.d.ts | 2 +- runtime/js/40_process.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 9c645882d687de..486d3e2f90e9c2 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -3394,6 +3394,7 @@ declare namespace Deno { /** Clean up resources associated with the sub-process instance. */ close(): void; /** Send a signal to process. + * Default signal is `"SIGTERM"`. * * ```ts * const p = Deno.run({ cmd: [ "sleep", "20" ]}); @@ -3401,11 +3402,11 @@ declare namespace Deno { * p.close(); * ``` */ - kill(signo: Signal): void; + kill(signo?: Signal): void; } /** Operating signals which can be listened for or sent to sub-processes. What - * signals and what their standard behaviors are are OS dependent. + * signals and what their standard behaviors are OS dependent. * * @category Runtime Environment */ export type Signal = @@ -4080,6 +4081,7 @@ declare namespace Deno { ): WebSocketUpgrade; /** Send a signal to process under given `pid`. + * Default signal is `"SIGTERM"`. * * If `pid` is negative, the signal will be sent to the process group * identified by `pid`. An error will be thrown if a negative @@ -4098,7 +4100,7 @@ declare namespace Deno { * @tags allow-run * @category Sub Process */ - export function kill(pid: number, signo: Signal): void; + export function kill(pid: number, signo?: Signal): void; /** The type of the resource record. * Only the listed types are supported currently. diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index a25c1011e80091..41f7a48d436f19 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1590,7 +1590,7 @@ declare namespace Deno { /** Waits for the child to exit completely, returning all its output and status. */ output(): Promise; - /** Kills the process with given Signal. Defaults to SIGTERM. */ + /** Kills the process with given Signal. Default signal is `"SIGTERM"`. */ kill(signo?: Signal): void; ref(): void; diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 76ce57fe382868..51cae9e66f8262 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -20,7 +20,7 @@ ops.op_kill(pid, signo, apiName); } - function kill(pid, signo) { + function kill(pid, signo = "SIGTERM") { opKill(pid, signo, "Deno.kill()"); } @@ -94,7 +94,7 @@ core.close(this.rid); } - kill(signo) { + kill(signo = "SIGTERM") { opKill(this.pid, signo, "Deno.Process.kill()"); } }