first commit

This commit is contained in:
Artem Anufrij
2026-10-07 18:56:27 +02:00
commit 2a8a60b725
7768 changed files with 1550851 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* Parses the `<ppid> <pid>` output produced by the ps/wmic/powershell backends
* into a list of `[ppid, pid]` pairs. The header row and any non-numeric lines
* are skipped, and all common line endings (\n, \r\n, \r\r\n) are handled.
* @param {string} stdout The raw command output.
* @returns {Array<[number, number]>}
*/
export function parse(stdout) {
const list = [];
for (const rawLine of stdout.split(/\r*\n/)) {
const line = rawLine.trim();
if (!line) continue;
const [rawPpid, rawPid] = line.split(/\s+/);
const ppid = Number.parseInt(rawPpid, 10);
const pid = Number.parseInt(rawPid, 10);
// Skips the header row and any stray output.
if (Number.isNaN(ppid) || Number.isNaN(pid)) continue;
list.push([ppid, pid]);
}
return list;
}