1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

feat: make Child.kill argument optional (#14669)

This commit is contained in:
Leo Kettmeir 2022-05-19 14:05:57 +02:00 committed by GitHub
parent 4e1ca1d178
commit 5ffcbcfcc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View file

@ -1060,8 +1060,8 @@ declare namespace Deno {
/** Waits for the child to exit completely, returning all its output and status. */
output(): Promise<SpawnOutput<T>>;
/** Kills the process with given Signal. */
kill(signo: Signal): void;
/** Kills the process with given Signal. Defaults to SIGTERM. */
kill(signo?: Signal): void;
}
/**

View file

@ -248,6 +248,29 @@ Deno.test(
},
);
Deno.test(
{ permissions: { run: true, read: true } },
async function spawnKillOptional() {
const child = Deno.spawnChild(Deno.execPath(), {
args: ["eval", "setTimeout(() => {}, 10000)"],
stdout: "null",
stderr: "null",
});
child.kill();
const status = await child.status;
assertEquals(status.success, false);
if (Deno.build.os === "windows") {
assertEquals(status.code, 1);
assertEquals(status.signal, null);
} else {
assertEquals(status.code, 143);
assertEquals(status.signal, "SIGTERM");
}
},
);
Deno.test(
{ permissions: { run: true, read: true } },
async function spawnAbort() {

View file

@ -165,7 +165,7 @@
};
}
kill(signo) {
kill(signo = "SIGTERM") {
if (this.#rid === null) {
throw new TypeError("Child process has already terminated.");
}