mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
18 lines
583 B
TypeScript
18 lines
583 B
TypeScript
import { exists } from "@std/fs/exists";
|
|
|
|
export async function check_running(pid: number | bigint) {
|
|
if (Deno.build.os == "windows") {
|
|
const cmd = new Deno.Command("tasklist.exe", {
|
|
args: ["/NH", "/FI", `pid eq ${pid}`],
|
|
stdout: "piped",
|
|
});
|
|
const c = cmd.spawn();
|
|
const o = await c.output();
|
|
if (o.code !== 0) return;
|
|
const s = (new TextDecoder()).decode(o.stdout);
|
|
return s.indexOf(`${pid}`) !== -1;
|
|
} else if (Deno.build.os == "linux") {
|
|
return await exists(`/proc/${pid}`);
|
|
}
|
|
}
|