mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 01:23: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(' ');
|
||||
|
||||
const { stdout } = await execFileAsync('powershell', [
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-Command',
|
||||
powershellCommand,
|
||||
]);
|
||||
const { stdout } = await execAsync(
|
||||
`powershell -NoProfile -NonInteractive -Command "${powershellCommand.replace(/"/g, '\\"')}"`,
|
||||
);
|
||||
const output = stdout.trim();
|
||||
if (!output) return { parentPid: 0, name: '', command: '' };
|
||||
const {
|
||||
@@ -234,22 +231,7 @@ async function getIdeProcessInfoForWindows(): Promise<{
|
||||
ancestors.push(curr);
|
||||
|
||||
if (curr.parentPid === 0 || !processMap.has(curr.parentPid)) {
|
||||
// Try to get info about the missing parent
|
||||
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
|
||||
}
|
||||
}
|
||||
// Parent process not in map, stop traversal
|
||||
break;
|
||||
}
|
||||
curr = processMap.get(curr.parentPid);
|
||||
|
||||
Reference in New Issue
Block a user