| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void start() { | 42 void start() { |
| 43 var status = new _ProcessStartStatus(); | 43 var status = new _ProcessStartStatus(); |
| 44 bool success = _start( | 44 bool success = _start( |
| 45 _path, _arguments, _in, _out, _err, _exitHandler, status); | 45 _path, _arguments, _in, _out, _err, _exitHandler, status); |
| 46 if (!success) { | 46 if (!success) { |
| 47 close(); | 47 close(); |
| 48 throw new ProcessException(status._errorMessage, status._errorCode); | 48 throw new ProcessException(status._errorMessage, status._errorCode); |
| 49 } | 49 } |
| 50 _started = true; | 50 _started = true; |
| 51 | 51 |
| 52 // Make sure to activate socket handlers now that the file |
| 53 // descriptors have been set. |
| 54 _in._activateHandlers(); |
| 55 _out._activateHandlers(); |
| 56 _err._activateHandlers(); |
| 57 |
| 52 // Setup an exit handler to handle internal cleanup and possible | 58 // Setup an exit handler to handle internal cleanup and possible |
| 53 // callback when a process terminates. | 59 // callback when a process terminates. |
| 54 _exitHandler.setDataHandler(() { | 60 _exitHandler.setDataHandler(() { |
| 55 final int EXIT_DATA_SIZE = 8; | 61 final int EXIT_DATA_SIZE = 8; |
| 56 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE); | 62 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE); |
| 57 InputStream input = _exitHandler.inputStream; | 63 InputStream input = _exitHandler.inputStream; |
| 58 int exitDataRead = 0; | 64 int exitDataRead = 0; |
| 59 | 65 |
| 60 int exitCode(List<int> ints) { | 66 int exitCode(List<int> ints) { |
| 61 return ints[4] + (ints[5] << 8) + (ints[6] << 16) + (ints[7] << 24); | 67 return ints[4] + (ints[5] << 8) + (ints[6] << 16) + (ints[7] << 24); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Socket _in; | 161 Socket _in; |
| 156 Socket _out; | 162 Socket _out; |
| 157 Socket _err; | 163 Socket _err; |
| 158 Socket _exitHandler; | 164 Socket _exitHandler; |
| 159 int _pid; | 165 int _pid; |
| 160 bool _closed; | 166 bool _closed; |
| 161 bool _killed; | 167 bool _killed; |
| 162 bool _started; | 168 bool _started; |
| 163 var _exitHandlerCallback; | 169 var _exitHandlerCallback; |
| 164 } | 170 } |
| OLD | NEW |