src/vs/base/common/processes.ts
153 LOC · 134 covered · 19 uncovered · 7 ranges · 2410 concepts · 4 introducers · 1173 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
processes.ts ×2
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IProcessEnvironment, isLinux } from './platform.js';
/**
* Options to be passed to the external program or shell.
*/
export interface CommandOptions {
/**
* The current working directory of the executed program or shell.
* If omitted VSCode's current workspace root is used.
*/
cwd?: string;
/**
* The environment of the executed program or shell. If omitted
* the parent process' environment is used.
*/
env?: { [key: string]: string };
}
export interface Executable {
/**
* The command to be executed. Can be an external program or a shell
* command.
*/
command: string;
/**
* Specifies whether the command is a shell command and therefore must
* be executed in a shell interpreter (e.g. cmd.exe, bash, ...).
*/
isShellCommand: boolean;
/**
* The arguments passed to the command.
*/
args: string[];
/**
* The command options used when the command is executed. Can be omitted.
*/
options?: CommandOptions;
}
export interface ForkOptions extends CommandOptions {
execArgv?: string[];
}
export const enum Source {
stdout,
stderr
}
/**
* The data send via a success callback
*/
export interface SuccessData {
error?: Error;
cmdCode?: number;
terminated?: boolean;
}
/**
* The data send via a error callback
*/
export interface ErrorData {
error?: Error;
terminated?: boolean;
stdout?: string;
stderr?: string;
}
export interface TerminateResponse {
success: boolean;
code?: TerminateResponseCode;
error?: any;
}
export const enum TerminateResponseCode {
Success = 0,
Unknown = 1,
AccessDenied = 2,
ProcessNotFound = 3,
}
export interface ProcessItem {
name: string;
cmd: string;
pid: number;
ppid: number;
load: number;
mem: number;
children?: ProcessItem[];
}
/**
* Sanitizes a VS Code process environment by removing all Electron/VS Code-related values.
*/
export function sanitizeProcessEnvironment(env: IProcessEnvironment, ...preserve: string[]): void {
return set;
const keysToRemove = [
/^ELECTRON_.+$/,
/^VSCODE_(?!(PORTABLE|SHELL_LOGIN|ENV_REPLACE|ENV_APPEND|ENV_PREPEND)).+$/,
/^SNAP(|_.*)$/,
/^GDK_PIXBUF_.+$/,
];
const envKeys = Object.keys(env);
envKeys
.filter(key => !set[key])
.forEach(envKey => {
for (let i = 0; i < keysToRemove.length; i++) {
if (envKey.search(keysToRemove[i]) !== -1) {
break;
}
});
}
/**
* Remove dangerous environment variables that have caused crashes
* in forked processes (i.e. in ELECTRON_RUN_AS_NODE processes)
*
* @param env The env object to change
*/
export function removeDangerousEnvVariables(env: IProcessEnvironment | undefined): void {
if (!env) {
return;
}
// Unset `DEBUG`, as an invalid value might lead to process crashes
// See https://github.com/microsoft/vscode/issues/130072
delete env['DEBUG'];
// Unset `NODE_OPTIONS`, as it can be used to inject arbitrary flags
// (e.g. `--require`, `--inspect`) into forked Node processes, which
// has caused crashes and unexpected behavior.
delete env['NODE_OPTIONS'];
if (isLinux) {
// Unset `LD_PRELOAD`, as it might lead to process crashes
// See https://github.com/microsoft/vscode/issues/134177
delete env['LD_PRELOAD'];
}
}