Skip to content
Browse files

stdio: Fix windows stdio pipes in streams2 land

Hopefully.
  • Loading branch information...
1 parent ec74555 commit 6377c814c65bc41dcf401bb97c57a4d15ba0e68d @isaacs committed Dec 21, 2012
Showing with 20 additions and 7 deletions.
  1. +5 −2 lib/net.js
  2. +15 −5 src/node.js
View
7 lib/net.js
@@ -141,10 +141,13 @@ function Socket(options) {
this._handle = options.handle; // private
} else if (typeof options.fd === 'undefined') {
this._handle = options && options.handle; // private
+ this.readable = options.readable !== false;
+ this.writable = options.writable !== false;
} else {
this._handle = createPipe();
this._handle.open(options.fd);
- this.readable = this.writable = true;
+ this.readable = options.readable !== false;
+ this.writable = options.writable !== false;
}
this.onend = null;
@@ -167,7 +170,7 @@ function Socket(options) {
// if we have a handle, then start the flow of data into the
// buffer. if not, then this will happen when we connect
- if (this._handle && (!options || options.readable !== false))
+ if (this._handle && options.readable !== false)
this.read(0);
}
util.inherits(Socket, stream.Duplex);
View
20 src/node.js
@@ -430,13 +430,18 @@
case 'PIPE':
var net = NativeModule.require('net');
- stream = new net.Stream(fd);
+ stream = new net.Socket({
+ fd: fd,
+ readable: false,
+ writable: true
+ });
- // FIXME Should probably have an option in net.Stream to create a
+ // FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we'll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
+ stream.read = null;
stream._type = 'pipe';
// FIXME Hack to have stream not keep the event loop alive.
@@ -498,7 +503,9 @@
var tty = NativeModule.require('tty');
stdin = new tty.ReadStream(fd, {
highWaterMark: 0,
- lowWaterMark: 0
+ lowWaterMark: 0,
+ readable: true,
+ writable: false
});
break;
@@ -509,8 +516,11 @@
case 'PIPE':
var net = NativeModule.require('net');
- stdin = new net.Stream({ fd: fd });
- stdin.readable = true;
+ stdin = new net.Socket({
+ fd: fd,
+ readable: true,
+ writable: false
+ });
break;
default:

0 comments on commit 6377c81

Please sign in to comment.
Something went wrong with that request. Please try again.