Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): make kill signal optional #16299

Merged
merged 4 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the intellisense/generated documentation is better if we do something like the following?

* @param [signo="SIGTERM"] - Signal to send to the process

https://jsdoc.app/tags-param.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting, didnt notice thats a thing. quickly checked, and deno_doc doesn't support it, so going to look into adding that first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should wait for microsoft/tsdoc#151 actually. Just noticed that.

Copy link
Member Author

@crowlKats crowlKats Oct 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, looking at that issue, made me notice microsoft/tsdoc#27, which we actually recently implemented... so maybe it would be fine? because i am in the need for default value for parameters for various documentation related things, so ideally we would implement it as per jsdoc spec. because i honestly have little hope that those tsdoc issues will get resolved anytime soon and being blocked on those for a massive improvement in documentation would just be silly...

*
* ```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