Skip to content

Commit 097cd38

Browse files
committed
Added missing util
1 parent 95a22e8 commit 097cd38

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from "node:fs"
2+
3+
export default async (pid, parentPid) => {
4+
try {
5+
const status = await fs.promises.readFile(`/proc/${pid}/status`, "utf8")
6+
7+
const match = status.match(/^PPid:\s+(\d+)/m)
8+
9+
if (match && match[1]) {
10+
const ppid = parseInt(match[1], 10)
11+
12+
return ppid === parentPid
13+
}
14+
15+
return false
16+
} catch (error) {
17+
console.error("Failed to check process:", error)
18+
return false
19+
}
20+
}

0 commit comments

Comments
 (0)