fix(ide): fix crash on windows when null command is returned (#8007)

Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
This commit is contained in:
Shreya Keshive
2025-09-08 10:53:28 -04:00
committed by GitHub
parent 009c24a4b8
commit 1788f04f5c

View File

@@ -44,11 +44,18 @@ async function getProcessInfo(pid: number): Promise<{
ParentProcessId = 0,
CommandLine = '',
} = JSON.parse(output);
return { parentPid: ParentProcessId, name: Name, command: CommandLine };
return {
parentPid: ParentProcessId,
name: Name,
command: CommandLine ?? '',
};
} else {
const command = `ps -o ppid=,command= -p ${pid}`;
const { stdout } = await execAsync(command);
const trimmedStdout = stdout.trim();
if (!trimmedStdout) {
return { parentPid: 0, name: '', command: '' };
}
const ppidString = trimmedStdout.split(/\s+/)[0];
const parentPid = parseInt(ppidString, 10);
const fullCommand = trimmedStdout.substring(ppidString.length).trim();