Skip to content

Commit

Permalink
Add pid check support for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc committed Jan 31, 2024
1 parent dece837 commit 6823d34
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pid_check.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { exists } from "std/fs/exists.ts";

export async function check_running(pid: number) {
if (Deno.build.os == "windows") {
const cmd = new Deno.Command("tasklist.exe", {
Expand All @@ -9,5 +11,7 @@ export async function check_running(pid: number) {
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}`);
}
}

0 comments on commit 6823d34

Please sign in to comment.