1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

feat(runtime): make kill signal optional (#16299)

This commit changes "Deno.kill()" method to have a default
value, that is "SIGTERM".
This commit is contained in:
Leo Kettmeir 2022-10-26 19:53:16 +02:00 committed by GitHub
parent 642118fdeb
commit 6ac603ec88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -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}.

View file

@ -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()");
}
}