message: Fixes Protect against Election 2.x crashes when spwaning and forking processes.
diff: @@ -72,8 +72,13 @@ export function resolveModule(workspaceRoot: string, moduleName: string): Thenab
  } else {
  newEnv[nodePathKey] = nodePath.join(separator);
  }
  + newEnv['ELECTRON_RUN_AS_NODE'] = '1';
  try {
  let cp: ChildProcess = fork(path.join(__dirname, 'resolve.js'), [], <any>{ env: newEnv, execArgv: [] });
  + if (cp.pid === void 0) {
  + reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
  + return;
  + }
  cp.on('message', (message: Message) => {
  if (message.command === 'resolve') {
  let toRequire: string = moduleName;
  @@ -144,13 +149,17 @@ export function resolve(moduleName: string, nodePath: string | undefined, cwd: s
  tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
  }
  }
  - newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
  + newEnv['ELECTRON_RUN_AS_NODE'] = '1';
  try {
  let cp: ChildProcess = fork('', [], <any>{
  cwd: cwd,
  env: newEnv,
  execArgv: ['-e', app]
  });
  + if (cp.pid === void 0) {
  + reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
  + return;
  + }
  cp.on('error', (error: any) => {
  reject(error);
  });
  @@ -186,6 +195,9 @@ export function resolveGlobalNodePath(tracer?: (message: string) => void): strin
  options.shell = true;
  }
  + let handler = () => {};
  + try {
  + process.on('SIGPIPE', handler);
  let stdout = spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
  if (!stdout) {
  @@ -207,6 +219,11 @@ export function resolveGlobalNodePath(tracer?: (message: string) => void): strin
  }
  }
  return undefined;
  + } catch (err) {
  + return undefined;
  + } finally {
  + process.removeListener('SIGPIPE', handler);
  + }
  }
  interface YarnJsonFormat {
  @@ -225,6 +242,9 @@ export function resolveGlobalYarnPath(tracer?: (message: string) => void): strin
  options.shell = true;
  }
  + let handler = () => {};
  + try {
  + process.on('SIGPIPE', handler);
  let results = spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
  let stdout = results.stdout;
  @@ -249,6 +269,11 @@ export function resolveGlobalYarnPath(tracer?: (message: string) => void): strin
  }
  }
  return undefined;
  + } catch (err) {
  + return undefined;
  + } finally {
  + process.removeListener('SIGPIPE', handler);
  + }
  }
  export namespace FileSystem {
  