fix(core): fix PTY descriptor shell leak (#16773)

This commit is contained in:
Gal Zahavi
2026-01-16 09:55:29 -08:00
committed by GitHub
parent be37c26c88
commit 013a4e02ff
4 changed files with 171 additions and 5 deletions

View File

@@ -5,6 +5,8 @@
*/
import os from 'node:os';
import fs from 'node:fs';
import path from 'node:path';
import { quote } from 'shell-quote';
import {
spawn,
@@ -37,6 +39,35 @@ export interface ShellConfiguration {
shell: ShellType;
}
export async function resolveExecutable(
exe: string,
): Promise<string | undefined> {
if (path.isAbsolute(exe)) {
try {
await fs.promises.access(exe, fs.constants.X_OK);
return exe;
} catch {
return undefined;
}
}
const paths = (process.env['PATH'] || '').split(path.delimiter);
const extensions =
os.platform() === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
for (const p of paths) {
for (const ext of extensions) {
const fullPath = path.join(p, exe + ext);
try {
await fs.promises.access(fullPath, fs.constants.X_OK);
return fullPath;
} catch {
continue;
}
}
}
return undefined;
}
let bashLanguage: Language | null = null;
let treeSitterInitialization: Promise<void> | null = null;
let treeSitterInitializationError: Error | null = null;