Fix process.stdout.end() throws ENOTSOCK error.
This commit is contained in:
parent
f918e57f8b
commit
0a51a6d3ac
@ -35,6 +35,12 @@ function ReadStream(fd) {
|
|||||||
if (!(this instanceof ReadStream)) return new ReadStream(fd);
|
if (!(this instanceof ReadStream)) return new ReadStream(fd);
|
||||||
net.Socket.call(this, fd);
|
net.Socket.call(this, fd);
|
||||||
|
|
||||||
|
if (this._writeWatcher) {
|
||||||
|
this._writeWatcher.stop();
|
||||||
|
this._writeWatcher = null;
|
||||||
|
}
|
||||||
|
this.writable = false;
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
keypressListeners = this.listeners('keypress');
|
keypressListeners = this.listeners('keypress');
|
||||||
|
|
||||||
@ -285,6 +291,12 @@ ReadStream.prototype._emitKey = function(s) {
|
|||||||
function WriteStream(fd) {
|
function WriteStream(fd) {
|
||||||
if (!(this instanceof WriteStream)) return new WriteStream(fd);
|
if (!(this instanceof WriteStream)) return new WriteStream(fd);
|
||||||
net.Socket.call(this, fd);
|
net.Socket.call(this, fd);
|
||||||
|
|
||||||
|
if (this._readWatcher) {
|
||||||
|
this._readWatcher.stop();
|
||||||
|
this._readWatcher = null;
|
||||||
|
}
|
||||||
|
this.readable = false;
|
||||||
}
|
}
|
||||||
inherits(WriteStream, net.Socket);
|
inherits(WriteStream, net.Socket);
|
||||||
exports.WriteStream = WriteStream;
|
exports.WriteStream = WriteStream;
|
||||||
|
12
test/disabled/test-tty-stdio.js
Normal file
12
test/disabled/test-tty-stdio.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Can't test this when 'make test' doesn't assign a tty to the stdout.
|
||||||
|
var common = require('../common');
|
||||||
|
var assert = require('assert');
|
||||||
|
var tty = require('tty');
|
||||||
|
|
||||||
|
assert.ok(process.stdin instanceof tty.ReadStream);
|
||||||
|
assert.ok(process.stdin.readable);
|
||||||
|
assert.ok(!process.stdin.writable);
|
||||||
|
|
||||||
|
assert.ok(process.stdout instanceof tty.WriteStream);
|
||||||
|
assert.ok(!process.stdout.readable);
|
||||||
|
assert.ok(process.stdout.writable);
|
14
test/simple/test-tty-stdout-end.js
Normal file
14
test/simple/test-tty-stdout-end.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Can't test this when 'make test' doesn't assign a tty to the stdout.
|
||||||
|
var common = require('../common');
|
||||||
|
var assert = require('assert');
|
||||||
|
var tty = require('tty');
|
||||||
|
|
||||||
|
var closed = false;
|
||||||
|
process.stdout.on('close', function() {
|
||||||
|
closed = true;
|
||||||
|
});
|
||||||
|
process.on('exit', function() {
|
||||||
|
assert.ok(closed);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stdout.end();
|
Loading…
x
Reference in New Issue
Block a user