mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
fixes #13561
This commit is contained in:
parent
3c6f232d05
commit
2f8c5c1189
|
@ -424,26 +424,6 @@ function getShellEnvironment(): TPromise<platform.IProcessEnvironment> {
|
|||
return getUnixShellEnvironment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user environment necessary for all Code processes.
|
||||
* Such environment needs to be propagated to the renderer/shared
|
||||
* processes.
|
||||
*/
|
||||
function getEnvironment(accessor: ServicesAccessor): TPromise<platform.IProcessEnvironment> {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
|
||||
return getShellEnvironment().then(shellEnv => {
|
||||
const instanceEnv = {
|
||||
VSCODE_PID: String(process.pid),
|
||||
VSCODE_IPC_HOOK: environmentService.mainIPCHandle,
|
||||
VSCODE_SHARED_IPC_HOOK: environmentService.sharedIPCHandle,
|
||||
VSCODE_NLS_CONFIG: process.env['VSCODE_NLS_CONFIG']
|
||||
};
|
||||
|
||||
return assign({}, shellEnv, instanceEnv);
|
||||
});
|
||||
}
|
||||
|
||||
function createPaths(environmentService: IEnvironmentService): TPromise<any> {
|
||||
const paths = [environmentService.appSettingsHome, environmentService.userHome, environmentService.extensionsPath];
|
||||
|
||||
|
@ -480,16 +460,30 @@ function start(): void {
|
|||
|
||||
// On some platforms we need to manually read from the global environment variables
|
||||
// and assign them to the process environment (e.g. when doubleclick app on Mac)
|
||||
return instantiationService.invokeFunction(accessor => {
|
||||
return getEnvironment(accessor).then(env => {
|
||||
assign(process.env, env);
|
||||
return getShellEnvironment().then(shellEnv => {
|
||||
// Patch `process.env` with the user's shell environment
|
||||
assign(process.env, shellEnv);
|
||||
|
||||
return instantiationService.invokeFunction(accessor => {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const instanceEnv = {
|
||||
VSCODE_PID: String(process.pid),
|
||||
VSCODE_IPC_HOOK: environmentService.mainIPCHandle,
|
||||
VSCODE_SHARED_IPC_HOOK: environmentService.sharedIPCHandle,
|
||||
VSCODE_NLS_CONFIG: process.env['VSCODE_NLS_CONFIG']
|
||||
};
|
||||
|
||||
// Patch `process.env` with the instance's environment
|
||||
assign(process.env, instanceEnv);
|
||||
|
||||
// Collect all environment patches to send to other processes
|
||||
const env = assign({}, shellEnv, instanceEnv);
|
||||
|
||||
return instantiationService.invokeFunction(a => createPaths(a.get(IEnvironmentService)))
|
||||
.then(() => instantiationService.invokeFunction(setupIPC))
|
||||
.then(mainIpcServer => instantiationService.invokeFunction(main, mainIpcServer, env));
|
||||
});
|
||||
})
|
||||
.done(null, err => instantiationService.invokeFunction(quit, err));
|
||||
}).done(null, err => instantiationService.invokeFunction(quit, err));
|
||||
}
|
||||
|
||||
start();
|
||||
|
|
|
@ -30,7 +30,7 @@ function getUniqueUserId(): string {
|
|||
return crypto.createHash('sha256').update(username).digest('hex').substr(0, 6);
|
||||
}
|
||||
|
||||
function getIPCHandleBaseName(): string {
|
||||
function getIPCHandlePrefix(): string {
|
||||
let name = pkg.name;
|
||||
|
||||
// Support to run VS Code multiple times as different user
|
||||
|
@ -47,8 +47,9 @@ function getIPCHandleBaseName(): string {
|
|||
return path.join(os.tmpdir(), name);
|
||||
}
|
||||
|
||||
const IPCHandlePrefix = getIPCHandleBaseName();
|
||||
const IPCHandleSuffix = process.platform === 'win32' ? '-sock' : '.sock';
|
||||
function getIPCHandleSuffix(): string {
|
||||
return process.platform === 'win32' ? '-sock' : '.sock';
|
||||
}
|
||||
|
||||
export class EnvironmentService implements IEnvironmentService {
|
||||
|
||||
|
@ -97,10 +98,10 @@ export class EnvironmentService implements IEnvironmentService {
|
|||
get logExtensionHostCommunication(): boolean { return this._args.logExtensionHostCommunication; }
|
||||
|
||||
@memoize
|
||||
get mainIPCHandle(): string { return `${IPCHandlePrefix}-${pkg.version}${IPCHandleSuffix}`; }
|
||||
get mainIPCHandle(): string { return `${getIPCHandlePrefix()}-${pkg.version}${getIPCHandleSuffix()}`; }
|
||||
|
||||
@memoize
|
||||
get sharedIPCHandle(): string { return `${IPCHandlePrefix}-${pkg.version}-shared${IPCHandleSuffix}`; }
|
||||
get sharedIPCHandle(): string { return `${getIPCHandlePrefix()}-${pkg.version}-shared${getIPCHandleSuffix()}`; }
|
||||
|
||||
constructor(private _args: ParsedArgs, private _execPath: string) { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue