| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class _ProcessStartStatus { | 5 class _ProcessStartStatus { |
| 6 int _errorCode; // Set to OS error code if process start failed. | 6 int _errorCode; // Set to OS error code if process start failed. |
| 7 String _errorMessage; // Set to OS error message if process start failed. | 7 String _errorMessage; // Set to OS error message if process start failed. |
| 8 } | 8 } |
| 9 | 9 |
| 10 | 10 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool _startNative(String path, | 193 bool _startNative(String path, |
| 194 List<String> arguments, | 194 List<String> arguments, |
| 195 String workingDirectory, | 195 String workingDirectory, |
| 196 List<String> environment, | 196 List<String> environment, |
| 197 Socket input, | 197 Socket input, |
| 198 Socket output, | 198 Socket output, |
| 199 Socket error, | 199 Socket error, |
| 200 Socket exitHandler, | 200 Socket exitHandler, |
| 201 _ProcessStartStatus status) native "Process_Start"; | 201 _ProcessStartStatus status) native "Process_Start"; |
| 202 | 202 |
| 203 InputStream get stdout() { | 203 InputStream get stdout { |
| 204 if (_closed) { | 204 if (_closed) { |
| 205 throw new ProcessException("Process closed"); | 205 throw new ProcessException("Process closed"); |
| 206 } | 206 } |
| 207 return _in.inputStream; | 207 return _in.inputStream; |
| 208 } | 208 } |
| 209 | 209 |
| 210 InputStream get stderr() { | 210 InputStream get stderr { |
| 211 if (_closed) { | 211 if (_closed) { |
| 212 throw new ProcessException("Process closed"); | 212 throw new ProcessException("Process closed"); |
| 213 } | 213 } |
| 214 return _err.inputStream; | 214 return _err.inputStream; |
| 215 } | 215 } |
| 216 | 216 |
| 217 OutputStream get stdin() { | 217 OutputStream get stdin { |
| 218 if (_closed) { | 218 if (_closed) { |
| 219 throw new ProcessException("Process closed"); | 219 throw new ProcessException("Process closed"); |
| 220 } | 220 } |
| 221 return _out.outputStream; | 221 return _out.outputStream; |
| 222 } | 222 } |
| 223 | 223 |
| 224 void kill([ProcessSignal signal = ProcessSignal.SIGTERM]) { | 224 void kill([ProcessSignal signal = ProcessSignal.SIGTERM]) { |
| 225 if (signal is! ProcessSignal) { | 225 if (signal is! ProcessSignal) { |
| 226 throw new IllegalArgumentException( | 226 throw new IllegalArgumentException( |
| 227 "Argument 'signal' must be a ProcessSignal"); | 227 "Argument 'signal' must be a ProcessSignal"); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 369 } |
| 370 | 370 |
| 371 void _checkDone() { | 371 void _checkDone() { |
| 372 if (_exitCode != null && _stderrClosed && _stdoutClosed) { | 372 if (_exitCode != null && _stderrClosed && _stdoutClosed) { |
| 373 _completer.complete(new _ProcessResult(_exitCode, | 373 _completer.complete(new _ProcessResult(_exitCode, |
| 374 _stdoutBuffer.toString(), | 374 _stdoutBuffer.toString(), |
| 375 _stderrBuffer.toString())); | 375 _stderrBuffer.toString())); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 Future<ProcessResult> get _result() => _completer.future; | 379 Future<ProcessResult> get _result => _completer.future; |
| 380 | 380 |
| 381 Completer<ProcessResult> _completer; | 381 Completer<ProcessResult> _completer; |
| 382 Process _process; | 382 Process _process; |
| 383 StringBuffer _stdoutBuffer; | 383 StringBuffer _stdoutBuffer; |
| 384 StringBuffer _stderrBuffer; | 384 StringBuffer _stderrBuffer; |
| 385 int _exitCode; | 385 int _exitCode; |
| 386 bool _stdoutClosed = false; | 386 bool _stdoutClosed = false; |
| 387 bool _stderrClosed = false; | 387 bool _stderrClosed = false; |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 class _ProcessResult implements ProcessResult { | 391 class _ProcessResult implements ProcessResult { |
| 392 const _ProcessResult(int this.exitCode, | 392 const _ProcessResult(int this.exitCode, |
| 393 String this.stdout, | 393 String this.stdout, |
| 394 String this.stderr); | 394 String this.stderr); |
| 395 | 395 |
| 396 final int exitCode; | 396 final int exitCode; |
| 397 final String stdout; | 397 final String stdout; |
| 398 final String stderr; | 398 final String stderr; |
| 399 } | 399 } |
| OLD | NEW |