Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: runtime/bin/process_impl.dart

Issue 9307033: Revert "Changes to the process implementation." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, 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
11 class _Process implements Process { 11 class _Process implements Process {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 // Make sure to activate socket handlers now that the file 80 // Make sure to activate socket handlers now that the file
81 // descriptors have been set. 81 // descriptors have been set.
82 _in._activateHandlers(); 82 _in._activateHandlers();
83 _out._activateHandlers(); 83 _out._activateHandlers();
84 _err._activateHandlers(); 84 _err._activateHandlers();
85 85
86 // Setup an exit handler to handle internal cleanup and possible 86 // Setup an exit handler to handle internal cleanup and possible
87 // callback when a process terminates. 87 // callback when a process terminates.
88 _exitHandler.inputStream.dataHandler = () { 88 _exitHandler.inputStream.dataHandler = () {
89 final int EXIT_DATA_SIZE = 8; 89 final int EXIT_DATA_SIZE = 12;
90 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE); 90 List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE);
91 int exitDataRead = 0; 91 int exitDataRead = 0;
92 92
93 int exitCode(List<int> ints) { 93 int exitCode(List<int> ints) {
94 var code = _intFromBytes(ints, 0); 94 var code = _intFromBytes(ints, 4);
95 var negative = _intFromBytes(ints, 4); 95 var negative = _intFromBytes(ints, 8);
96 assert(negative == 0 || negative == 1); 96 assert(negative == 0 || negative == 1);
97 return (negative == 0) ? code : -code; 97 return (negative == 0) ? code : -code;
98 } 98 }
99 99
100 int exitPid(List<int> ints) {
101 return _intFromBytes(ints, 0);
102 }
103
100 void handleExit() { 104 void handleExit() {
105 _processExit(exitPid(exitDataBuffer));
101 if (_exitHandlerCallback !== null) { 106 if (_exitHandlerCallback !== null) {
102 _exitHandlerCallback(exitCode(exitDataBuffer)); 107 _exitHandlerCallback(exitCode(exitDataBuffer));
103 } 108 }
104 } 109 }
105 110
106 exitDataRead += _exitHandler.inputStream.readInto( 111 exitDataRead += _exitHandler.inputStream.readInto(
107 exitDataBuffer, exitDataRead, EXIT_DATA_SIZE - exitDataRead); 112 exitDataBuffer, exitDataRead, EXIT_DATA_SIZE - exitDataRead);
108 if (exitDataRead == EXIT_DATA_SIZE) handleExit(); 113 if (exitDataRead == EXIT_DATA_SIZE) handleExit();
109 }; 114 };
110 115
111 if (_startHandler !== null) { 116 if (_startHandler !== null) {
112 _startHandler(); 117 _startHandler();
113 } 118 }
114 } 119 }
115 120
116 bool _start(String path, 121 bool _start(String path,
117 List<String> arguments, 122 List<String> arguments,
118 String workingDirectory, 123 String workingDirectory,
119 Socket input, 124 Socket input,
120 Socket output, 125 Socket output,
121 Socket error, 126 Socket error,
122 Socket exitHandler, 127 Socket exitHandler,
123 _ProcessStartStatus status) native "Process_Start"; 128 _ProcessStartStatus status) native "Process_Start";
124 129
130 void _processExit(int pid) native "Process_Exit";
131
125 InputStream get stdout() { 132 InputStream get stdout() {
126 if (_closed) { 133 if (_closed) {
127 throw new ProcessException("Process closed"); 134 throw new ProcessException("Process closed");
128 } 135 }
129 return _in.inputStream; 136 return _in.inputStream;
130 } 137 }
131 138
132 InputStream get stderr() { 139 InputStream get stderr() {
133 if (_closed) { 140 if (_closed) {
134 throw new ProcessException("Process closed"); 141 throw new ProcessException("Process closed");
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 Socket _err; 210 Socket _err;
204 Socket _exitHandler; 211 Socket _exitHandler;
205 int _pid; 212 int _pid;
206 bool _closed; 213 bool _closed;
207 bool _killed; 214 bool _killed;
208 bool _started; 215 bool _started;
209 Function _exitHandlerCallback; 216 Function _exitHandlerCallback;
210 Function _errorHandler; 217 Function _errorHandler;
211 Function _startHandler; 218 Function _startHandler;
212 } 219 }
OLDNEW
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698