diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2022-10-26 19:53:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 19:53:16 +0200 |
commit | 6ac603ec883868776399514ca5ed42f882691405 (patch) | |
tree | 18c601c13894a572075ea37eaeb7206b5b720fed | |
parent | 642118fdeb06817636fe03d0d8428fbd7927094d (diff) |
feat(runtime): make kill signal optional (#16299)
This commit changes "Deno.kill()" method to have a default
value, that is "SIGTERM".
-rw-r--r-- | cli/dts/lib.deno.ns.d.ts | 10 | ||||
-rw-r--r-- | runtime/js/40_process.js | 4 |
2 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 22f0409fe..518b81edd 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -3439,6 +3439,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" ]}); @@ -3446,11 +3447,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 = @@ -4471,7 +4472,8 @@ declare namespace Deno { /** Send a signal to process under given `pid`. The value and meaning of the * `signal` to the process is operating system and process dependant. - * {@linkcode Signal} provides the most common signals. + * {@linkcode Signal} provides the most common signals. Default signal + * is `"SIGTERM"`. * * The term `kill` is adopted from the UNIX-like command line command `kill` * which also signals processes. @@ -4493,7 +4495,7 @@ declare namespace Deno { * @tags allow-run * @category Sub Process */ - export function kill(pid: number, signal: Signal): void; + export function kill(pid: number, signo?: Signal): void; /** The type of the resource record to resolve via DNS using * {@linkcode Deno.resolveDns}. diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 76ce57fe3..51cae9e66 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()"); } } |