Get mac launching with mostly root env

Part of #70248
This commit is contained in:
Daniel Imms
2019-06-12 18:07:41 -07:00
parent ce84b4afab
commit 78dfd041de
@@ -98,10 +98,29 @@ export class TerminalInstanceService implements ITerminalInstanceService {
this._mainProcessParentEnv = env;
}
// For macOS just return the root environment which seems to always be {}, this is the
// parent of the main process when code is launched from the dock.
// For macOS it doesn't appear to be possible to get the "root" environment as
// `ps eww -o command` for PID 1 (the parent of the main process when launched from the
// dock/finder) returns no environment, because of this we will fill in the root environment
// using a whitelist of environment variables that we have.
if (isMacintosh) {
this._mainProcessParentEnv = {};
// This list was generated by diffing launching a terminal with {} and the system
// terminal launched from finder.
const rootEnvVars = [
'SHELL',
'SSH_AUTH_SOCK',
'Apple_PubSub_Socket_Render',
'XPC_FLAGS',
'XPC_SERVICE_NAME',
'HOME',
'LOGNAME',
'TMPDIR'
];
rootEnvVars.forEach(k => {
if (process.env[k]) {
this._mainProcessParentEnv![k] = process.env[k]!;
}
});
}
// TODO: Windows should return a fresh environment block, might need native code?