From 6ac0337165d5e341eee9bff9ff0065894289df69 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 10 Oct 2021 09:48:26 -0400 Subject: feat: Stabilize Deno.kill and Deno.Process.kill (#12375) Co-authored-by: Luca Casonato --- cli/dts/lib.deno.ns.d.ts | 56 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'cli/dts/lib.deno.ns.d.ts') diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 35d02776e..e1c23f10f 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -1956,14 +1956,46 @@ declare namespace Deno { stderrOutput(): Promise; close(): void; - /** **UNSTABLE** - * - * Send a signal to process. This functionality currently only works on - * Linux and Mac OS. + /** Send a signal to process. */ - kill(signo: string): void; // TODO(ry): Use Signal type here once made stable. + kill(signo: Signal): void; } + export type Signal = + | "SIGABRT" + | "SIGALRM" + | "SIGBUS" + | "SIGCHLD" + | "SIGCONT" + | "SIGEMT" + | "SIGFPE" + | "SIGHUP" + | "SIGILL" + | "SIGINFO" + | "SIGINT" + | "SIGIO" + | "SIGKILL" + | "SIGPIPE" + | "SIGPROF" + | "SIGPWR" + | "SIGQUIT" + | "SIGSEGV" + | "SIGSTKFLT" + | "SIGSTOP" + | "SIGSYS" + | "SIGTERM" + | "SIGTRAP" + | "SIGTSTP" + | "SIGTTIN" + | "SIGTTOU" + | "SIGURG" + | "SIGUSR1" + | "SIGUSR2" + | "SIGVTALRM" + | "SIGWINCH" + | "SIGXCPU" + | "SIGXFSZ"; + export type ProcessStatus = | { success: true; @@ -2481,6 +2513,20 @@ declare namespace Deno { options?: UpgradeWebSocketOptions, ): WebSocketUpgrade; + /** Send a signal to process under given `pid`. + * + * If `pid` is negative, the signal will be sent to the process group + * identified by `pid`. + * + * const p = Deno.run({ + * cmd: ["sleep", "10000"] + * }); + * + * Deno.kill(p.pid, "SIGINT"); + * + * Requires `allow-run` permission. */ + export function kill(pid: number, signo: Signal): void; + /** The type of the resource record. * Only the listed types are supported currently. */ export type RecordType = -- cgit v1.2.3