OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 patch class _WindowsCodePageDecoder { | 5 patch class _WindowsCodePageDecoder { |
6 /* patch */ static String _decodeBytes(List<int> bytes) | 6 /* patch */ static String _decodeBytes(List<int> bytes) |
7 native "SystemEncodingToString"; | 7 native "SystemEncodingToString"; |
8 } | 8 } |
9 | 9 |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // Use default Map so we keep order. | 181 // Use default Map so we keep order. |
182 static Map<int, _ProcessImpl> _processes = new Map<int, _ProcessImpl>(); | 182 static Map<int, _ProcessImpl> _processes = new Map<int, _ProcessImpl>(); |
183 | 183 |
184 _ProcessImpl(String path, | 184 _ProcessImpl(String path, |
185 List<String> arguments, | 185 List<String> arguments, |
186 String this._workingDirectory, | 186 String this._workingDirectory, |
187 Map<String, String> environment, | 187 Map<String, String> environment, |
188 bool includeParentEnvironment, | 188 bool includeParentEnvironment, |
189 bool runInShell, | 189 bool runInShell, |
190 ProcessStartMode mode) : super() { | 190 ProcessStartMode mode) : super() { |
191 _processes[_serviceId] = this; | |
192 if (runInShell) { | 191 if (runInShell) { |
193 arguments = _getShellArguments(path, arguments); | 192 arguments = _getShellArguments(path, arguments); |
194 path = _getShellCommand(); | 193 path = _getShellCommand(); |
195 } | 194 } |
196 | 195 |
197 if (path is !String) { | 196 if (path is !String) { |
198 throw new ArgumentError("Path is not a String: $path"); | 197 throw new ArgumentError("Path is not a String: $path"); |
199 } | 198 } |
200 _path = path; | 199 _path = path; |
201 | 200 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 var negative = _intFromBytes(ints, 4); | 431 var negative = _intFromBytes(ints, 4); |
433 assert(negative == 0 || negative == 1); | 432 assert(negative == 0 || negative == 1); |
434 return (negative == 0) ? code : -code; | 433 return (negative == 0) ? code : -code; |
435 } | 434 } |
436 | 435 |
437 void handleExit() { | 436 void handleExit() { |
438 _ended = true; | 437 _ended = true; |
439 _exitCode.complete(exitCode(exitDataBuffer)); | 438 _exitCode.complete(exitCode(exitDataBuffer)); |
440 // Kill stdin, helping hand if the user forgot to do it. | 439 // Kill stdin, helping hand if the user forgot to do it. |
441 _stdin._sink.destroy(); | 440 _stdin._sink.destroy(); |
442 _processes.remove(_serviceId); | |
443 } | 441 } |
444 | 442 |
445 exitDataBuffer.setRange( | 443 exitDataBuffer.setRange( |
446 exitDataRead, exitDataRead + data.length, data); | 444 exitDataRead, exitDataRead + data.length, data); |
447 exitDataRead += data.length; | 445 exitDataRead += data.length; |
448 if (exitDataRead == EXIT_DATA_SIZE) { | 446 if (exitDataRead == EXIT_DATA_SIZE) { |
449 handleExit(); | 447 handleExit(); |
450 } | 448 } |
451 }); | 449 }); |
452 } | 450 } |
(...skipping 28 matching lines...) Expand all Loading... |
481 _stdin._sink._nativeSocket, | 479 _stdin._sink._nativeSocket, |
482 _stdout._stream._nativeSocket, | 480 _stdout._stream._nativeSocket, |
483 _stderr._stream._nativeSocket, | 481 _stderr._stream._nativeSocket, |
484 _exitHandler._nativeSocket); | 482 _exitHandler._nativeSocket); |
485 | 483 |
486 getOutput(output, encoding) { | 484 getOutput(output, encoding) { |
487 if (encoding == null) return output; | 485 if (encoding == null) return output; |
488 return encoding.decode(output); | 486 return encoding.decode(output); |
489 } | 487 } |
490 | 488 |
491 _processes.remove(_serviceId); | |
492 | |
493 return new ProcessResult( | 489 return new ProcessResult( |
494 result[0], | 490 result[0], |
495 result[1], | 491 result[1], |
496 getOutput(result[2], stdoutEncoding), | 492 getOutput(result[2], stdoutEncoding), |
497 getOutput(result[3], stderrEncoding)); | 493 getOutput(result[3], stderrEncoding)); |
498 } | 494 } |
499 | 495 |
500 bool _startNative(String path, | 496 bool _startNative(String path, |
501 List<String> arguments, | 497 List<String> arguments, |
502 String workingDirectory, | 498 String workingDirectory, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 Encoding stderrEncoding) { | 614 Encoding stderrEncoding) { |
619 var process = new _ProcessImpl(executable, | 615 var process = new _ProcessImpl(executable, |
620 arguments, | 616 arguments, |
621 workingDirectory, | 617 workingDirectory, |
622 environment, | 618 environment, |
623 includeParentEnvironment, | 619 includeParentEnvironment, |
624 runInShell, | 620 runInShell, |
625 ProcessStartMode.NORMAL); | 621 ProcessStartMode.NORMAL); |
626 return process._runAndWait(stdoutEncoding, stderrEncoding); | 622 return process._runAndWait(stdoutEncoding, stderrEncoding); |
627 } | 623 } |
OLD | NEW |