提交 d5e4540b 编写于 作者: J Joao Moreno

allow IO from shared process in dev

上级 41c4d496
......@@ -90,16 +90,18 @@ if (!!process.send && process.env.PIPE_LOGGING === 'true') {
console.error = function () { safeSend({ type: '__$console', severity: 'error', arguments: safeStringify(arguments) }); };
}
// Let stdout, stderr and stdin be no-op streams. This prevents an issue where we would get an EBADF
// error when we are inside a forked process and this process tries to access those channels.
var stream = require('stream');
var writable = new stream.Writable({
write: function () { /* No OP */ }
});
process.__defineGetter__('stdout', function() { return writable; });
process.__defineGetter__('stderr', function() { return writable; });
process.__defineGetter__('stdin', function() { return writable; });
if (!process.env['VSCODE_ALLOW_IO']) {
// Let stdout, stderr and stdin be no-op streams. This prevents an issue where we would get an EBADF
// error when we are inside a forked process and this process tries to access those channels.
var stream = require('stream');
var writable = new stream.Writable({
write: function () { /* No OP */ }
});
process.__defineGetter__('stdout', function() { return writable; });
process.__defineGetter__('stderr', function() { return writable; });
process.__defineGetter__('stdin', function() { return writable; });
}
// Handle uncaught exceptions
process.on('uncaughtException', function (err) {
......
......@@ -108,7 +108,7 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
process.env['VSCODE_SHARED_IPC_HOOK'] = envService.sharedIPCHandle;
// Spawn shared process
const sharedProcess = instantiationService.invokeFunction(spawnSharedProcess);
const sharedProcess = spawnSharedProcess(!envService.isBuilt || envService.cliArgs.verboseLogging);
// Make sure we associate the program with the app user model id
// This will help Windows to associate the running program with
......
......@@ -7,15 +7,18 @@ import * as cp from 'child_process';
import URI from 'vs/base/common/uri';
import { IDisposable } from 'vs/base/common/lifecycle';
import { assign } from 'vs/base/common/objects';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
const boostrapPath = URI.parse(require.toUrl('bootstrap')).fsPath;
function _spawnSharedProcess(): cp.ChildProcess {
function _spawnSharedProcess(allowOutput: boolean): cp.ChildProcess {
const env = assign({}, process.env, {
AMD_ENTRYPOINT: 'vs/code/node/sharedProcessMain'
});
if (allowOutput) {
env['VSCODE_ALLOW_IO'] = 'true';
}
const result = cp.fork(boostrapPath, ['--type=SharedProcess'], { env });
// handshake
......@@ -26,7 +29,7 @@ function _spawnSharedProcess(): cp.ChildProcess {
let spawnCount = 0;
export function spawnSharedProcess(accessor: ServicesAccessor): IDisposable {
export function spawnSharedProcess(allowOutput: boolean): IDisposable {
let child: cp.ChildProcess;
const spawn = () => {
......@@ -34,7 +37,7 @@ export function spawnSharedProcess(accessor: ServicesAccessor): IDisposable {
return;
}
child = _spawnSharedProcess();
child = _spawnSharedProcess(allowOutput);
child.on('exit', spawn);
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册