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

Unified Diff: runtime/bin/process_impl.dart

Issue 8506013: Correct the sign of exit codes for the process library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index da02ccb578e0922743b2f3bf77c98b88861f9acf..4cb462b4fe954c1cd02bd843675f3a3b678639c5 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -39,6 +39,13 @@ class _Process implements Process {
_exitHandlerCallback = null;
}
+ int _intFromBytes(List<int> bytes, int offset) {
+ return (bytes[offset] +
+ (bytes[offset + 1] << 8) +
+ (bytes[offset + 2] << 16) +
+ (bytes[offset + 3] << 24));
+ }
+
void start() {
var status = new _ProcessStartStatus();
bool success = _start(
@@ -58,17 +65,20 @@ class _Process implements Process {
// Setup an exit handler to handle internal cleanup and possible
// callback when a process terminates.
_exitHandler.dataHandler = () {
- final int EXIT_DATA_SIZE = 8;
+ final int EXIT_DATA_SIZE = 12;
List<int> exitDataBuffer = new List<int>(EXIT_DATA_SIZE);
InputStream input = _exitHandler.inputStream;
int exitDataRead = 0;
int exitCode(List<int> ints) {
- return ints[4] + (ints[5] << 8) + (ints[6] << 16) + (ints[7] << 24);
+ var code = _intFromBytes(ints, 4);
+ var negative = _intFromBytes(ints, 8);
+ assert(negative == 0 || negative == 1);
+ return (negative == 0) ? code : -code;
}
int exitPid(List<int> ints) {
- return ints[0] + (ints[1] << 8) + (ints[2] << 16) + (ints[3] << 24);
+ return _intFromBytes(ints, 0);
}
void handleExit() {
« no previous file with comments | « no previous file | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698