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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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.dataHandler = () { | 60 _exitHandler.dataHandler = () { |
61 final int EXIT_DATA_SIZE = 8; | 61 final int EXIT_DATA_SIZE = 12; |
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 var code = |
68 ints[4] + (ints[5] << 8) + (ints[6] << 16) + (ints[7] << 24); | |
69 return (ints[8] == 0) ? code : -code; | |
Søren Gjesse
2011/11/09 15:12:45
Should we assert that ints[8] is either 0 or 1 and
Mads Ager (google)
2011/11/09 15:37:11
Thanks! Done. I'm using that method to get the neg
| |
68 } | 70 } |
69 | 71 |
70 int exitPid(List<int> ints) { | 72 int exitPid(List<int> ints) { |
71 return ints[0] + (ints[1] << 8) + (ints[2] << 16) + (ints[3] << 24); | 73 return ints[0] + (ints[1] << 8) + (ints[2] << 16) + (ints[3] << 24); |
72 } | 74 } |
73 | 75 |
74 void handleExit() { | 76 void handleExit() { |
75 _processExit(exitPid(exitDataBuffer)); | 77 _processExit(exitPid(exitDataBuffer)); |
76 if (_exitHandlerCallback !== null) { | 78 if (_exitHandlerCallback !== null) { |
77 _exitHandlerCallback(exitCode(exitDataBuffer)); | 79 _exitHandlerCallback(exitCode(exitDataBuffer)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 Socket _in; | 163 Socket _in; |
162 Socket _out; | 164 Socket _out; |
163 Socket _err; | 165 Socket _err; |
164 Socket _exitHandler; | 166 Socket _exitHandler; |
165 int _pid; | 167 int _pid; |
166 bool _closed; | 168 bool _closed; |
167 bool _killed; | 169 bool _killed; |
168 bool _started; | 170 bool _started; |
169 var _exitHandlerCallback; | 171 var _exitHandlerCallback; |
170 } | 172 } |
OLD | NEW |