| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 _started = true; | 50 _started = true; |
| 51 | 51 |
| 52 // Make sure to activate socket handlers now that the file | 52 // Make sure to activate socket handlers now that the file |
| 53 // descriptors have been set. | 53 // descriptors have been set. |
| 54 _in._activateHandlers(); | 54 _in._activateHandlers(); |
| 55 _out._activateHandlers(); | 55 _out._activateHandlers(); |
| 56 _err._activateHandlers(); | 56 _err._activateHandlers(); |
| 57 | 57 |
| 58 // Setup an exit handler to handle internal cleanup and possible | 58 // Setup an exit handler to handle internal cleanup and possible |
| 59 // callback when a process terminates. | 59 // callback when a process terminates. |
| 60 _exitHandler.setDataHandler(() { | 60 _exitHandler.dataHandler = () { |
| 61 final int EXIT_DATA_SIZE = 8; | 61 final int EXIT_DATA_SIZE = 8; |
| 62 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE); | 62 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE); |
| 63 InputStream input = _exitHandler.inputStream; | 63 InputStream input = _exitHandler.inputStream; |
| 64 int exitDataRead = 0; | 64 int exitDataRead = 0; |
| 65 | 65 |
| 66 int exitCode(List<int> ints) { | 66 int exitCode(List<int> ints) { |
| 67 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); |
| 68 } | 68 } |
| 69 | 69 |
| 70 int exitPid(List<int> ints) { | 70 int exitPid(List<int> ints) { |
| 71 return ints[0] + (ints[1] << 8) + (ints[2] << 16) + (ints[3] << 24); | 71 return ints[0] + (ints[1] << 8) + (ints[2] << 16) + (ints[3] << 24); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void handleExit() { | 74 void handleExit() { |
| 75 _processExit(exitPid(exitDataBuffer)); | 75 _processExit(exitPid(exitDataBuffer)); |
| 76 if (_exitHandlerCallback !== null) { | 76 if (_exitHandlerCallback !== null) { |
| 77 _exitHandlerCallback(exitCode(exitDataBuffer)); | 77 _exitHandlerCallback(exitCode(exitDataBuffer)); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 void exitData() { | 81 void exitData() { |
| 82 exitDataRead += input.readInto( | 82 exitDataRead += input.readInto( |
| 83 exitDataBuffer, exitDataRead, EXIT_DATA_SIZE - exitDataRead); | 83 exitDataBuffer, exitDataRead, EXIT_DATA_SIZE - exitDataRead); |
| 84 if (exitDataRead == EXIT_DATA_SIZE) handleExit(); | 84 if (exitDataRead == EXIT_DATA_SIZE) handleExit(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 input.dataHandler = exitData; | 87 input.dataHandler = exitData; |
| 88 }); | 88 }; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool _start(String path, | 91 bool _start(String path, |
| 92 List<String> arguments, | 92 List<String> arguments, |
| 93 Socket input, | 93 Socket input, |
| 94 Socket output, | 94 Socket output, |
| 95 Socket error, | 95 Socket error, |
| 96 Socket exitHandler, | 96 Socket exitHandler, |
| 97 _ProcessStartStatus status) native "Process_Start"; | 97 _ProcessStartStatus status) native "Process_Start"; |
| 98 | 98 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 Socket _in; | 161 Socket _in; |
| 162 Socket _out; | 162 Socket _out; |
| 163 Socket _err; | 163 Socket _err; |
| 164 Socket _exitHandler; | 164 Socket _exitHandler; |
| 165 int _pid; | 165 int _pid; |
| 166 bool _closed; | 166 bool _closed; |
| 167 bool _killed; | 167 bool _killed; |
| 168 bool _started; | 168 bool _started; |
| 169 var _exitHandlerCallback; | 169 var _exitHandlerCallback; |
| 170 } | 170 } |
| OLD | NEW |