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(
|
||||||
(
|
pids.map((pid) =>
|
||||||
await Promise.all(
|
readlink(`/proc/${pid}/exe`).then(
|
||||||
out
|
(path) => [+pid, path],
|
||||||
.toString()
|
() => {}
|
||||||
.split("\n")
|
)
|
||||||
.slice(1, -1)
|
)
|
||||||
.map(async (x) => {
|
)
|
||||||
const split = x.trim().split(";");
|
).filter((x) => x);
|
||||||
// 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])
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
module.exports = {getProcesses};
|
module.exports = {getProcesses};
|
||||||
|
|
Loading…
Reference in a new issue