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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 _in, | 150 _in, |
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 var arguments = Strings.join(_arguments, ' '); | |
160 completer.completeException( | 161 completer.completeException( |
161 new ProcessException(status._errorMessage, status._errorCode)); | 162 new ProcessException('$_path $arguments', |
Søren Gjesse
2012/11/16 12:45:02
We could also place path and arguments on the Proc
Mads Ager (google)
2012/11/16 13:00:30
Done.
| |
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 var arguments = Strings.join(_arguments, ' '); |
252 throw new ProcessException("$_path $arguments", "Process killed"); | |
249 } | 253 } |
250 _onExit = callback; | 254 _onExit = callback; |
251 } | 255 } |
252 | 256 |
253 String _path; | 257 String _path; |
254 List<String> _arguments; | 258 List<String> _arguments; |
255 String _workingDirectory; | 259 String _workingDirectory; |
256 List<String> _environment; | 260 List<String> _environment; |
257 // Private methods of _Socket are used by _in, _out, and _err. | 261 // Private methods of _Socket are used by _in, _out, and _err. |
258 _Socket _in; | 262 _Socket _in; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 | 363 |
360 class _ProcessResult implements ProcessResult { | 364 class _ProcessResult implements ProcessResult { |
361 const _ProcessResult(int this.exitCode, | 365 const _ProcessResult(int this.exitCode, |
362 String this.stdout, | 366 String this.stdout, |
363 String this.stderr); | 367 String this.stderr); |
364 | 368 |
365 final int exitCode; | 369 final int exitCode; |
366 final String stdout; | 370 final String stdout; |
367 final String stderr; | 371 final String stderr; |
368 } | 372 } |
OLD | NEW |