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 patch class Process { | 5 patch class Process { |
6 /* patch */ static Future<Process> start(String executable, | 6 /* patch */ static Future<Process> start(String executable, |
7 List<String> arguments, | 7 List<String> arguments, |
8 [ProcessOptions options]) { | 8 [ProcessOptions options]) { |
9 _ProcessImpl process = new _ProcessImpl(executable, arguments, options); | 9 _ProcessImpl process = new _ProcessImpl(executable, arguments, options); |
10 return process._start(); | 10 return process._start(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 _out, | 151 _out, |
152 _err, | 152 _err, |
153 _exitHandler, | 153 _exitHandler, |
154 status); | 154 status); |
155 if (!success) { | 155 if (!success) { |
156 _in.close(); | 156 _in.close(); |
157 _out.close(); | 157 _out.close(); |
158 _err.close(); | 158 _err.close(); |
159 _exitHandler.close(); | 159 _exitHandler.close(); |
160 completer.completeException( | 160 completer.completeException( |
161 new ProcessException(status._errorMessage, status._errorCode)); | 161 new ProcessException(_path, |
| 162 _arguments, |
| 163 status._errorMessage, |
| 164 status._errorCode)); |
162 return; | 165 return; |
163 } | 166 } |
164 _started = true; | 167 _started = true; |
165 | 168 |
166 _in._closed = false; | 169 _in._closed = false; |
167 _out._closed = false; | 170 _out._closed = false; |
168 _err._closed = false; | 171 _err._closed = false; |
169 _exitHandler._closed = false; | 172 _exitHandler._closed = false; |
170 | 173 |
171 // Make sure to activate socket handlers now that the file | 174 // Make sure to activate socket handlers now that the file |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 241 } |
239 assert(_started); | 242 assert(_started); |
240 if (_ended) return false; | 243 if (_ended) return false; |
241 return _kill(this, signal._signalNumber); | 244 return _kill(this, signal._signalNumber); |
242 } | 245 } |
243 | 246 |
244 bool _kill(Process p, int signal) native "Process_Kill"; | 247 bool _kill(Process p, int signal) native "Process_Kill"; |
245 | 248 |
246 void set onExit(void callback(int exitCode)) { | 249 void set onExit(void callback(int exitCode)) { |
247 if (_ended) { | 250 if (_ended) { |
248 throw new ProcessException("Process killed"); | 251 throw new ProcessException(_path, _arguments, "Process killed"); |
249 } | 252 } |
250 _onExit = callback; | 253 _onExit = callback; |
251 } | 254 } |
252 | 255 |
253 String _path; | 256 String _path; |
254 List<String> _arguments; | 257 List<String> _arguments; |
255 String _workingDirectory; | 258 String _workingDirectory; |
256 List<String> _environment; | 259 List<String> _environment; |
257 // Private methods of _Socket are used by _in, _out, and _err. | 260 // Private methods of _Socket are used by _in, _out, and _err. |
258 _Socket _in; | 261 _Socket _in; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 362 |
360 class _ProcessResult implements ProcessResult { | 363 class _ProcessResult implements ProcessResult { |
361 const _ProcessResult(int this.exitCode, | 364 const _ProcessResult(int this.exitCode, |
362 String this.stdout, | 365 String this.stdout, |
363 String this.stderr); | 366 String this.stderr); |
364 | 367 |
365 final int exitCode; | 368 final int exitCode; |
366 final String stdout; | 369 final String stdout; |
367 final String stderr; | 370 final String stderr; |
368 } | 371 } |
OLD | NEW |