|
@ -71,12 +71,9 @@ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
startup.globalConsole = function() { |
|
|
startup.globalConsole = function() { |
|
|
global.__defineGetter__('console', function() { |
|
|
global.console = NativeModule.require('console'); |
|
|
return NativeModule.require('console'); |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startup._lazyConstants = null; |
|
|
startup._lazyConstants = null; |
|
|
|
|
|
|
|
|
startup.lazyConstants = function() { |
|
|
startup.lazyConstants = function() { |
|
@ -126,32 +123,29 @@ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
startup.processStdio = function() { |
|
|
startup.processStdio = function() { |
|
|
var stdout, stdin; |
|
|
var binding = process.binding('stdio'), |
|
|
|
|
|
net = NativeModule.require('net'), |
|
|
process.__defineGetter__('stdout', function() { |
|
|
fs = NativeModule.require('fs'), |
|
|
if (stdout) return stdout; |
|
|
tty = NativeModule.require('tty'); |
|
|
|
|
|
|
|
|
var binding = process.binding('stdio'), |
|
|
// process.stdout
|
|
|
net = NativeModule.require('net'), |
|
|
|
|
|
fs = NativeModule.require('fs'), |
|
|
var fd = binding.stdoutFD; |
|
|
tty = NativeModule.require('tty'), |
|
|
|
|
|
fd = binding.stdoutFD; |
|
|
if (binding.isatty(fd)) { |
|
|
|
|
|
process.stdout = new tty.WriteStream(fd); |
|
|
if (binding.isatty(fd)) { |
|
|
} else if (binding.isStdoutBlocking()) { |
|
|
stdout = new tty.WriteStream(fd); |
|
|
process.stdout = new fs.WriteStream(null, {fd: fd}); |
|
|
} else if (binding.isStdoutBlocking()) { |
|
|
} else { |
|
|
stdout = new fs.WriteStream(null, {fd: fd}); |
|
|
process.stdout = new net.Stream(fd); |
|
|
} else { |
|
|
// FIXME Should probably have an option in net.Stream to create a
|
|
|
stdout = new net.Stream(fd); |
|
|
// stream from an existing fd which is writable only. But for now
|
|
|
// FIXME Should probably have an option in net.Stream to create a
|
|
|
// we'll just add this hack and set the `readable` member to false.
|
|
|
// stream from an existing fd which is writable only. But for now
|
|
|
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
|
|
// we'll just add this hack and set the `readable` member to false.
|
|
|
process.stdout.readable = false; |
|
|
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
|
|
} |
|
|
stdout.readable = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return stdout; |
|
|
// process.stderr
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var events = NativeModule.require('events'); |
|
|
var events = NativeModule.require('events'); |
|
|
var stderr = process.stderr = new events.EventEmitter(); |
|
|
var stderr = process.stderr = new events.EventEmitter(); |
|
@ -160,26 +154,18 @@ |
|
|
stderr.write = process.binding('stdio').writeError; |
|
|
stderr.write = process.binding('stdio').writeError; |
|
|
stderr.end = stderr.destroy = stderr.destroySoon = function() { }; |
|
|
stderr.end = stderr.destroy = stderr.destroySoon = function() { }; |
|
|
|
|
|
|
|
|
process.__defineGetter__('stdin', function() { |
|
|
// process.stdin
|
|
|
if (stdin) return stdin; |
|
|
|
|
|
|
|
|
|
|
|
var binding = process.binding('stdio'), |
|
|
var fd = binding.openStdin(); |
|
|
net = NativeModule.require('net'), |
|
|
|
|
|
fs = NativeModule.require('fs'), |
|
|
|
|
|
tty = NativeModule.require('tty'), |
|
|
|
|
|
fd = binding.openStdin(); |
|
|
|
|
|
|
|
|
|
|
|
if (binding.isatty(fd)) { |
|
|
if (binding.isatty(fd)) { |
|
|
stdin = new tty.ReadStream(fd); |
|
|
process.stdin = new tty.ReadStream(fd); |
|
|
} else if (binding.isStdinBlocking()) { |
|
|
} else if (binding.isStdinBlocking()) { |
|
|
stdin = new fs.ReadStream(null, {fd: fd}); |
|
|
process.stdin = new fs.ReadStream(null, {fd: fd}); |
|
|
} else { |
|
|
} else { |
|
|
stdin = new net.Stream(fd); |
|
|
process.stdin = new net.Stream(fd); |
|
|
stdin.readable = true; |
|
|
process.stdin.readable = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return stdin; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
process.openStdin = function() { |
|
|
process.openStdin = function() { |
|
|
process.stdin.resume(); |
|
|
process.stdin.resume(); |
|
|