Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: pass env variables to child process on z/OS #42255

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const {

const MAX_BUFFER = 1024 * 1024;

const isZOS = process.platform === 'os390';

/**
* Spawns a new Node.js process + fork.
* @param {string|URL} modulePath
Expand Down Expand Up @@ -524,6 +526,14 @@ ObjectDefineProperty(execFile, promisify.custom, {
value: customPromiseExecFunction(execFile)
});

function copyProcessEnvToEnv(env, name, optionEnv) {
if (process.env[name] &&
(!optionEnv ||
!ObjectPrototypeHasOwnProperty(optionEnv, name))) {
env[name] = process.env[name];
}
}

function normalizeSpawnArguments(file, args, options) {
validateString(file, 'file');

Expand Down Expand Up @@ -630,9 +640,19 @@ function normalizeSpawnArguments(file, args, options) {

// process.env.NODE_V8_COVERAGE always propagates, making it possible to
// collect coverage for programs that spawn with white-listed environment.
if (process.env.NODE_V8_COVERAGE &&
!ObjectPrototypeHasOwnProperty(options.env || {}, 'NODE_V8_COVERAGE')) {
env.NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE;
copyProcessEnvToEnv(env, 'NODE_V8_COVERAGE', options.env);

if (isZOS) {
// The following environment variables must always propagate if set.
copyProcessEnvToEnv(env, '_BPXK_AUTOCVT', options.env);
copyProcessEnvToEnv(env, '_CEE_RUNOPTS', options.env);
copyProcessEnvToEnv(env, '_TAG_REDIR_ERR', options.env);
copyProcessEnvToEnv(env, '_TAG_REDIR_IN', options.env);
copyProcessEnvToEnv(env, '_TAG_REDIR_OUT', options.env);
copyProcessEnvToEnv(env, 'STEPLIB', options.env);
copyProcessEnvToEnv(env, 'LIBPATH', options.env);
copyProcessEnvToEnv(env, '_EDC_SIG_DFLT', options.env);
copyProcessEnvToEnv(env, '_EDC_SUSV3', options.env);
}

let envKeys = [];
Expand Down