| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1dddfec commit c371fdc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -230,12 +230,16 @@ util.inherits(ChildProcess, EventEmitter); | |||
| 230 | 230 | ||
| 231 | 231 | ||
| 232 | 232 | function flushStdio(subprocess) { | |
| 233 | - if (subprocess.stdio == null) return; | ||
| 234 | - subprocess.stdio.forEach(function(stream, fd, stdio) { | ||
| 233 | + const stdio = subprocess.stdio; | ||
| 234 | + | ||
| 235 | + if (stdio == null) return; | ||
| 236 | + | ||
| 237 | + for (var i = 0; i < stdio.length; i++) { | ||
| 238 | + const stream = stdio[i]; | ||
| 235 | 239 | if (!stream || !stream.readable || stream._readableState.readableListening) | |
| 236 | - return; | ||
| 240 | + continue; | ||
| 237 | 241 | stream.resume(); | |
| 238 | - }); | ||
| 242 | + } | ||
| 239 | 243 | } | |
| 240 | 244 | ||
| 241 | 245 | ||
@@ -268,6 +272,7 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 268 | 272 | const self = this; | |
| 269 | 273 | var ipc; | |
| 270 | 274 | var ipcFd; | |
| 275 | + var i; | ||
| 271 | 276 | // If no `stdio` option was given - use default | |
| 272 | 277 | var stdio = options.stdio || 'pipe'; | |
| 273 | 278 | ||
@@ -302,11 +307,12 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 302 | 307 | if (err !== uv.UV_ENOENT) return err; | |
| 303 | 308 | } else if (err) { | |
| 304 | 309 | // Close all opened fds on error | |
| 305 | - stdio.forEach(function(stdio) { | ||
| 306 | - if (stdio.type === 'pipe') { | ||
| 307 | - stdio.handle.close(); | ||
| 310 | + for (i = 0; i < stdio.length; i++) { | ||
| 311 | + const stream = stdio[i]; | ||
| 312 | + if (stream.type === 'pipe') { | ||
| 313 | + stream.handle.close(); | ||
| 308 | 314 | } | |
| 309 | - }); | ||
| 315 | + } | ||
| 310 | 316 | ||
| 311 | 317 | this._handle.close(); | |
| 312 | 318 | this._handle = null; | |
@@ -315,27 +321,29 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 315 | 321 | ||
| 316 | 322 | this.pid = this._handle.pid; | |
| 317 | 323 | ||
| 318 | - stdio.forEach(function(stdio, i) { | ||
| 319 | - if (stdio.type === 'ignore') return; | ||
| 324 | + for (i = 0; i < stdio.length; i++) { | ||
| 325 | + const stream = stdio[i]; | ||
| 326 | + if (stream.type === 'ignore') continue; | ||
| 320 | 327 | ||
| 321 | - if (stdio.ipc) { | ||
| 328 | + if (stream.ipc) { | ||
| 322 | 329 | self._closesNeeded++; | |
| 323 | - return; | ||
| 330 | + continue; | ||
| 324 | 331 | } | |
| 325 | 332 | ||
| 326 | - if (stdio.handle) { | ||
| 333 | + if (stream.handle) { | ||
| 327 | 334 | // when i === 0 - we're dealing with stdin | |
| 328 | 335 | // (which is the only one writable pipe) | |
| 329 | - stdio.socket = createSocket(self.pid !== 0 ? stdio.handle : null, i > 0); | ||
| 336 | + stream.socket = createSocket(self.pid !== 0 ? | ||
| 337 | + stream.handle : null, i > 0); | ||
| 330 | 338 | ||
| 331 | 339 | if (i > 0 && self.pid !== 0) { | |
| 332 | 340 | self._closesNeeded++; | |
| 333 | - stdio.socket.on('close', function() { | ||
| 341 | + stream.socket.on('close', function() { | ||
| 334 | 342 | maybeClose(self); | |
| 335 | 343 | }); | |
| 336 | 344 | } | |
| 337 | 345 | } | |
| 338 | - }); | ||
| 346 | + } | ||
| 339 | 347 | ||
| 340 | 348 | this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ? | |
| 341 | 349 | stdio[0].socket : null; | |
@@ -783,11 +791,11 @@ function _validateStdio(stdio, sync) { | |||
| 783 | 791 | } | |
| 784 | 792 | ||
| 785 | 793 | // Defaults | |
| 786 | - if (stdio === null || stdio === undefined) { | ||
| 794 | + if (stdio == null) { | ||
| 787 | 795 | stdio = i < 3 ? 'pipe' : 'ignore'; | |
| 788 | 796 | } | |
| 789 | 797 | ||
| 790 | - if (stdio === null || stdio === 'ignore') { | ||
| 798 | + if (stdio === 'ignore') { | ||
| 791 | 799 | acc.push({type: 'ignore'}); | |
| 792 | 800 | } else if (stdio === 'pipe' || typeof stdio === 'number' && stdio < 0) { | |
| 793 | 801 | var a = { | |
@@ -873,7 +881,7 @@ function getSocketList(type, slave, key) { | |||
| 873 | 881 | function maybeClose(subprocess) { | |
| 874 | 882 | subprocess._closesGot++; | |
| 875 | 883 | ||
| 876 | - if (subprocess._closesGot == subprocess._closesNeeded) { | ||
| 884 | + if (subprocess._closesGot === subprocess._closesNeeded) { | ||
| 877 | 885 | subprocess.emit('close', subprocess.exitCode, subprocess.signalCode); | |
| 878 | 886 | } | |
| 879 | 887 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments