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, readdir} = require("fs/promises");
|
||||||
const {readlink} = require("fs/promises");
|
|
||||||
|
|
||||||
const getProcesses = () =>
|
const getProcesses = async () => {
|
||||||
new Promise((res) =>
|
const pids = (await readdir("/proc")).filter((f) => !isNaN(+f));
|
||||||
exec(`ps a -o "%p;%c;%a"`, async (e, out) => {
|
return (
|
||||||
res(
|
|
||||||
(
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
out
|
pids.map((pid) =>
|
||||||
.toString()
|
readlink(`/proc/${pid}/exe`).then(
|
||||||
.split("\n")
|
(path) => [+pid, path],
|
||||||
.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];
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
).filter((x) => x && x[1])
|
)
|
||||||
);
|
)
|
||||||
})
|
).filter((x) => x);
|
||||||
);
|
};
|
||||||
module.exports = {getProcesses};
|
module.exports = {getProcesses};
|
||||||
|
|
Loading…
Reference in a new issue