diff --git a/src/main/ts/ps.ts b/src/main/ts/ps.ts index eb9a231..2555f1c 100644 --- a/src/main/ts/ps.ts +++ b/src/main/ts/ps.ts @@ -6,10 +6,12 @@ import { exec, type TSpawnCtx } from 'zurk/spawn' const IS_WIN = process.platform === 'win32' const IS_WIN2025_PLUS = IS_WIN && Number.parseInt(os.release().split('.')[2], 10) >= 26_000 // WMIC will be missing in Windows 11 25H2 (kernel >= 26000) +const IS_BUSYBOX = !IS_WIN && fs.existsSync('/bin/busybox') const LOOKUPS: Record TIngridResponse + fallback?: string }> = { wmic: { cmd: 'wmic process get ProcessId,ParentProcessId,CommandLine', @@ -21,6 +23,14 @@ const LOOKUPS: Record { if (err) { reject(err) cb(err) return } - result.push(...filterProcessList(normalizeOutput(parse(stdout)), query)) + const parsed = filterProcessList(normalizeOutput(parse(stdout)), query) + if (parsed.length === 0 && lookup.fallback) { + const fb = LOOKUPS[lookup.fallback] + exec({ + cmd: fb.cmd, + args: fb.args, + callback: (err2, {stdout: stdout2}) => { + if (err2) { + resolve(result) + cb(null, result) + return + } + result.push(...filterProcessList(normalizeOutput(fb.parse(stdout2)), query)) + resolve(result) + cb(null, result) + }, + sync, + run(cb) { cb() }, + }) + return + } + result.push(...parsed) resolve(result) cb(null, result) }