mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
refactor(core): optimize Windows process detection and remove debug logging
- Replace execFileAsync with execAsync for complex PowerShell commands in getProcessInfo - Remove unnecessary getProcessInfo retry logic when parent not in processMap - Remove all debug logging code (writeDebugLog function and fs import) - Improve performance by ~1.6-2.6 seconds per detection - Keep execFileAsync for simple commands in getProcessTableWindows
This commit is contained in:
@@ -38,12 +38,9 @@ async function getProcessInfo(pid: number): Promise<{
|
|||||||
'}',
|
'}',
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
||||||
const { stdout } = await execFileAsync('powershell', [
|
const { stdout } = await execAsync(
|
||||||
'-NoProfile',
|
`powershell -NoProfile -NonInteractive -Command "${powershellCommand.replace(/"/g, '\\"')}"`,
|
||||||
'-NonInteractive',
|
);
|
||||||
'-Command',
|
|
||||||
powershellCommand,
|
|
||||||
]);
|
|
||||||
const output = stdout.trim();
|
const output = stdout.trim();
|
||||||
if (!output) return { parentPid: 0, name: '', command: '' };
|
if (!output) return { parentPid: 0, name: '', command: '' };
|
||||||
const {
|
const {
|
||||||
@@ -234,22 +231,7 @@ async function getIdeProcessInfoForWindows(): Promise<{
|
|||||||
ancestors.push(curr);
|
ancestors.push(curr);
|
||||||
|
|
||||||
if (curr.parentPid === 0 || !processMap.has(curr.parentPid)) {
|
if (curr.parentPid === 0 || !processMap.has(curr.parentPid)) {
|
||||||
// Try to get info about the missing parent
|
// Parent process not in map, stop traversal
|
||||||
if (curr.parentPid !== 0) {
|
|
||||||
try {
|
|
||||||
const parentInfo = await getProcessInfo(curr.parentPid);
|
|
||||||
if (parentInfo.name) {
|
|
||||||
ancestors.push({
|
|
||||||
pid: curr.parentPid,
|
|
||||||
parentPid: parentInfo.parentPid,
|
|
||||||
name: parentInfo.name,
|
|
||||||
command: parentInfo.command,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (_e) {
|
|
||||||
// Ignore if query fails
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curr = processMap.get(curr.parentPid);
|
curr = processMap.get(curr.parentPid);
|
||||||
|
|||||||
Reference in New Issue
Block a user