summaryrefslogtreecommitdiff
path: root/lib/child_process.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/child_process.js')
-rw-r--r--lib/child_process.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index 972f68ce27..ecd7559abb 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -709,9 +709,10 @@ ChildProcess.prototype.spawn = function(options) {
}
// At least 3 stdio will be created
- if (stdio.length < 3) {
- stdio = stdio.concat(new Array(3 - stdio.length));
- }
+ // Don't concat() a new Array() because it would be sparse, and
+ // stdio.reduce() would skip the sparse elements of stdio.
+ // See http://stackoverflow.com/a/5501711/3561
+ while (stdio.length < 3) stdio.push(undefined);
// Translate stdio into C++-readable form
// (i.e. PipeWraps or fds)