fix(runtime): ChildProcess::kill() doesn't require additional perms (#15339)

Fixes #15217.
This commit is contained in:
Nayeem Rahman 2023-05-11 13:53:45 +01:00 committed by GitHub
parent 20c42286f8
commit 2ba9ccc1ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 13 deletions

View file

@ -200,6 +200,7 @@ function collectOutput(readableStream) {
class ChildProcess {
#rid;
#waitPromiseId;
#waitComplete = false;
#unrefed = false;
#pid;
@ -268,8 +269,8 @@ class ChildProcess {
const waitPromise = core.opAsync("op_spawn_wait", this.#rid);
this.#waitPromiseId = waitPromise[promiseIdSymbol];
this.#status = PromisePrototypeThen(waitPromise, (res) => {
this.#rid = null;
signal?.[abortSignal.remove](onAbort);
this.#waitComplete = true;
return res;
});
}
@ -317,10 +318,10 @@ class ChildProcess {
}
kill(signo = "SIGTERM") {
if (this.#rid === null) {
if (this.#waitComplete) {
throw new TypeError("Child process has already terminated.");
}
ops.op_kill(this.#pid, signo, "Deno.Child.kill()");
ops.op_spawn_kill(this.#rid, signo);
}
ref() {