Skip to content

Commit

Permalink
Get mac launching with mostly root env
Browse files Browse the repository at this point in the history
Part of #70248
  • Loading branch information
Tyriar committed Jun 13, 2019
1 parent ce84b4a commit 78dfd04
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 78dfd04

Please sign in to comment.