Skip to content

Commit

Permalink
feat(runtime): make kill signal optional (denoland#16299)
Browse files Browse the repository at this point in the history
This commit changes "Deno.kill()" method to have a default
value, that is "SIGTERM".
  • Loading branch information
crowlKats authored Oct 26, 2022
1 parent 642118f commit 6ac603e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions cli/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3439,18 +3439,19 @@ 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" ]});
* p.kill("SIGTERM");
* 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 =
Expand Down Expand Up @@ -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.
Expand All @@ -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}.
Expand Down
4 changes: 2 additions & 2 deletions runtime/js/40_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ops.op_kill(pid, signo, apiName);
}

function kill(pid, signo) {
function kill(pid, signo = "SIGTERM") {
opKill(pid, signo, "Deno.kill()");
}

Expand Down Expand Up @@ -94,7 +94,7 @@
core.close(this.rid);
}

kill(signo) {
kill(signo = "SIGTERM") {
opKill(this.pid, signo, "Deno.Process.kill()");
}
}
Expand Down

0 comments on commit 6ac603e

Please sign in to comment.