mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
fetch from upstream arrpc
This commit is contained in:
parent
ebe2e6d693
commit
da141beb3e
1 changed files with 14 additions and 29 deletions
|
@ -1,31 +1,16 @@
|
|||
const {exec} = require("child_process");
|
||||
const {readlink} = require("fs/promises");
|
||||
const {readlink, readdir} = require("fs/promises");
|
||||
|
||||
const getProcesses = () =>
|
||||
new Promise((res) =>
|
||||
exec(`ps a -o "%p;%c;%a"`, async (e, out) => {
|
||||
res(
|
||||
(
|
||||
const getProcesses = async () => {
|
||||
const pids = (await readdir("/proc")).filter((f) => !isNaN(+f));
|
||||
return (
|
||||
await Promise.all(
|
||||
out
|
||||
.toString()
|
||||
.split("\n")
|
||||
.slice(1, -1)
|
||||
.map(async (x) => {
|
||||
const split = x.trim().split(";");
|
||||
// if (split.length === 1) return;
|
||||
|
||||
const pid = parseInt(split[0].trim());
|
||||
const cmd = split[1].trim();
|
||||
const argv = split.slice(2).join(";").trim();
|
||||
|
||||
const path = await readlink(`/proc/${pid}/exe`).catch((e) => {}); // read path from /proc/{pid}/exe symlink
|
||||
|
||||
return [pid, path];
|
||||
})
|
||||
pids.map((pid) =>
|
||||
readlink(`/proc/${pid}/exe`).then(
|
||||
(path) => [+pid, path],
|
||||
() => {}
|
||||
)
|
||||
).filter((x) => x && x[1])
|
||||
);
|
||||
})
|
||||
);
|
||||
)
|
||||
)
|
||||
).filter((x) => x);
|
||||
};
|
||||
module.exports = {getProcesses};
|
||||
|
|
Loading…
Reference in a new issue