| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 28471c2 commit 2b867d2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,12 +226,16 @@ util.inherits(ChildProcess, EventEmitter); | |||
| 226 | 226 | ||
| 227 | 227 | ||
| 228 | 228 | function flushStdio(subprocess) { | |
| 229 | - if (subprocess.stdio == null) return; | ||
| 230 | - subprocess.stdio.forEach(function(stream, fd, stdio) { | ||
| 229 | + const stdio = subprocess.stdio; | ||
| 230 | + | ||
| 231 | + if (stdio == null) return; | ||
| 232 | + | ||
| 233 | + for (var i = 0; i < stdio.length; i++) { | ||
| 234 | + const stream = stdio[i]; | ||
| 231 | 235 | if (!stream || !stream.readable || stream._readableState.readableListening) | |
| 232 | - return; | ||
| 236 | + continue; | ||
| 233 | 237 | stream.resume(); | |
| 234 | - }); | ||
| 238 | + } | ||
| 235 | 239 | } | |
| 236 | 240 | ||
| 237 | 241 | ||
@@ -264,6 +268,7 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 264 | 268 | const self = this; | |
| 265 | 269 | var ipc; | |
| 266 | 270 | var ipcFd; | |
| 271 | + var i; | ||
| 267 | 272 | // If no `stdio` option was given - use default | |
| 268 | 273 | var stdio = options.stdio || 'pipe'; | |
| 269 | 274 | ||
@@ -298,11 +303,12 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 298 | 303 | if (err !== uv.UV_ENOENT) return err; | |
| 299 | 304 | } else if (err) { | |
| 300 | 305 | // Close all opened fds on error | |
| 301 | - stdio.forEach(function(stdio) { | ||
| 302 | - if (stdio.type === 'pipe') { | ||
| 303 | - stdio.handle.close(); | ||
| 306 | + for (i = 0; i < stdio.length; i++) { | ||
| 307 | + const stream = stdio[i]; | ||
| 308 | + if (stream.type === 'pipe') { | ||
| 309 | + stream.handle.close(); | ||
| 304 | 310 | } | |
| 305 | - }); | ||
| 311 | + } | ||
| 306 | 312 | ||
| 307 | 313 | this._handle.close(); | |
| 308 | 314 | this._handle = null; | |
@@ -311,27 +317,29 @@ ChildProcess.prototype.spawn = function(options) { | |||
| 311 | 317 | ||
| 312 | 318 | this.pid = this._handle.pid; | |
| 313 | 319 | ||
| 314 | - stdio.forEach(function(stdio, i) { | ||
| 315 | - if (stdio.type === 'ignore') return; | ||
| 320 | + for (i = 0; i < stdio.length; i++) { | ||
| 321 | + const stream = stdio[i]; | ||
| 322 | + if (stream.type === 'ignore') continue; | ||
| 316 | 323 | ||
| 317 | - if (stdio.ipc) { | ||
| 324 | + if (stream.ipc) { | ||
| 318 | 325 | self._closesNeeded++; | |
| 319 | - return; | ||
| 326 | + continue; | ||
| 320 | 327 | } | |
| 321 | 328 | ||
| 322 | - if (stdio.handle) { | ||
| 329 | + if (stream.handle) { | ||
| 323 | 330 | // when i === 0 - we're dealing with stdin | |
| 324 | 331 | // (which is the only one writable pipe) | |
| 325 | - stdio.socket = createSocket(self.pid !== 0 ? stdio.handle : null, i > 0); | ||
| 332 | + stream.socket = createSocket(self.pid !== 0 ? | ||
| 333 | + stream.handle : null, i > 0); | ||
| 326 | 334 | ||
| 327 | 335 | if (i > 0 && self.pid !== 0) { | |
| 328 | 336 | self._closesNeeded++; | |
| 329 | - stdio.socket.on('close', function() { | ||
| 337 | + stream.socket.on('close', function() { | ||
| 330 | 338 | maybeClose(self); | |
| 331 | 339 | }); | |
| 332 | 340 | } | |
| 333 | 341 | } | |
| 334 | - }); | ||
| 342 | + } | ||
| 335 | 343 | ||
| 336 | 344 | this.stdin = stdio.length >= 1 && stdio[0].socket !== undefined ? | |
| 337 | 345 | stdio[0].socket : null; | |
@@ -760,11 +768,11 @@ function _validateStdio(stdio, sync) { | |||
| 760 | 768 | } | |
| 761 | 769 | ||
| 762 | 770 | // Defaults | |
| 763 | - if (stdio === null || stdio === undefined) { | ||
| 771 | + if (stdio == null) { | ||
| 764 | 772 | stdio = i < 3 ? 'pipe' : 'ignore'; | |
| 765 | 773 | } | |
| 766 | 774 | ||
| 767 | - if (stdio === null || stdio === 'ignore') { | ||
| 775 | + if (stdio === 'ignore') { | ||
| 768 | 776 | acc.push({type: 'ignore'}); | |
| 769 | 777 | } else if (stdio === 'pipe' || typeof stdio === 'number' && stdio < 0) { | |
| 770 | 778 | var a = { | |
@@ -850,7 +858,7 @@ function getSocketList(type, slave, key) { | |||
| 850 | 858 | function maybeClose(subprocess) { | |
| 851 | 859 | subprocess._closesGot++; | |
| 852 | 860 | ||
| 853 | - if (subprocess._closesGot == subprocess._closesNeeded) { | ||
| 861 | + if (subprocess._closesGot === subprocess._closesNeeded) { | ||
| 854 | 862 | subprocess.emit('close', subprocess.exitCode, subprocess.signalCode); | |
| 855 | 863 | } | |
| 856 | 864 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments