File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ Stream.prototype.pipe = function(dest, options) {
5454 // If the 'end' option is not supplied, dest.end() will be called when
5555 // source gets the 'end' or 'close' events. Only dest.end() once, and
5656 // only when all sources have ended.
57- if ( ! options || options . end !== false ) {
57+ if ( ! dest . _isStdio && ( ! options || options . end !== false ) ) {
5858 dest . _pipeCount = dest . _pipeCount || 0 ;
5959 dest . _pipeCount ++ ;
6060
Original file line number Diff line number Diff line change 269269 // For supporting legacy API we put the FD here.
270270 stream . fd = fd ;
271271
272+ stream . _isStdio = true ;
273+
272274 return stream ;
273275 }
274276
278280 process . __defineGetter__ ( 'stdout' , function ( ) {
279281 if ( stdout ) return stdout ;
280282 stdout = createWritableStdioStream ( 1 ) ;
281- stdout . end = stdout . destroy = stdout . destroySoon = function ( ) { } ;
283+ stdout . end = stdout . destroy = stdout . destroySoon = function ( ) {
284+ throw new Error ( 'process.stdout cannot be closed' ) ;
285+ } ;
282286 return stdout ;
283287 } ) ;
284288
285289 process . __defineGetter__ ( 'stderr' , function ( ) {
286290 if ( stderr ) return stderr ;
287291 stderr = createWritableStdioStream ( 2 ) ;
288- stderr . end = stderr . destroy = stderr . destroySoon = function ( ) { } ;
292+ stderr . end = stderr . destroy = stderr . destroySoon = function ( ) {
293+ throw new Error ( 'process.stderr cannot be closed' ) ;
294+ } ;
289295 return stderr ;
290296 } ) ;
291297
Original file line number Diff line number Diff line change 2222// Can't test this when 'make test' doesn't assign a tty to the stdout.
2323var common = require ( '../common' ) ;
2424var assert = require ( 'assert' ) ;
25- var tty = require ( 'tty' ) ;
2625
27- var closed = false ;
28- process . stdout . on ( 'close' , function ( ) {
29- closed = true ;
30- } ) ;
31- process . on ( 'exit' , function ( ) {
32- assert . ok ( closed ) ;
33- } ) ;
26+ var exceptionCaught = false ;
3427
35- process . stdout . end ( ) ;
28+ try {
29+ process . stdout . end ( ) ;
30+ } catch ( e ) {
31+ exceptionCaught = true ;
32+ assert . ok ( common . isError ( e ) ) ;
33+ assert . equal ( 'process.stdout cannot be closed' , e . message ) ;
34+ }
35+
36+ assert . ok ( exceptionCaught ) ;
You can’t perform that action at this time.
0 commit comments