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

Side by Side Diff: runtime/bin/process_win.cc

Issue 85393002: Change process exit codes on Windows to always be positive (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « no previous file | no next file » | 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) 2012, 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include <process.h> // NOLINT 8 #include <process.h> // NOLINT
9 9
10 #include "bin/builtin.h" 10 #include "bin/builtin.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 bool success = LookupProcess(pid, &handle, &wait_handle, &exit_pipe); 148 bool success = LookupProcess(pid, &handle, &wait_handle, &exit_pipe);
149 if (!success) { 149 if (!success) {
150 FATAL("Failed to lookup process in list of active processes"); 150 FATAL("Failed to lookup process in list of active processes");
151 } 151 }
152 // Unregister the event in a non-blocking way. 152 // Unregister the event in a non-blocking way.
153 BOOL ok = UnregisterWait(wait_handle); 153 BOOL ok = UnregisterWait(wait_handle);
154 if (!ok && GetLastError() != ERROR_IO_PENDING) { 154 if (!ok && GetLastError() != ERROR_IO_PENDING) {
155 FATAL("Failed unregistering wait operation"); 155 FATAL("Failed unregistering wait operation");
156 } 156 }
157 // Get and report the exit code to Dart. 157 // Get and report the exit code to Dart.
158 int exit_code; 158 DWORD exit_code;
159 ok = GetExitCodeProcess(handle, 159 ok = GetExitCodeProcess(handle,
160 reinterpret_cast<DWORD*>(&exit_code)); 160 reinterpret_cast<DWORD*>(&exit_code));
161 if (!ok) { 161 if (!ok) {
162 FATAL1("GetExitCodeProcess failed %d\n", GetLastError()); 162 FATAL1("GetExitCodeProcess failed %d\n", GetLastError());
163 } 163 }
164 int negative = 0; 164 int message[2] = { exit_code, 0 };
165 if (exit_code < 0) {
166 exit_code = abs(exit_code);
167 negative = 1;
168 }
169 int message[2] = { exit_code, negative };
170 DWORD written; 165 DWORD written;
171 ok = WriteFile(exit_pipe, message, sizeof(message), &written, NULL); 166 ok = WriteFile(exit_pipe, message, sizeof(message), &written, NULL);
172 // If the process has been closed, the read end of the exit 167 // If the process has been closed, the read end of the exit
173 // pipe has been closed. It is therefore not a problem that 168 // pipe has been closed. It is therefore not a problem that
174 // WriteFile fails with a closed pipe error 169 // WriteFile fails with a closed pipe error
175 // (ERROR_NO_DATA). Other errors should not happen. 170 // (ERROR_NO_DATA). Other errors should not happen.
176 if (ok && written != sizeof(message)) { 171 if (ok && written != sizeof(message)) {
177 FATAL("Failed to write entire process exit message"); 172 FATAL("Failed to write entire process exit message");
178 } else if (!ok && GetLastError() != ERROR_NO_DATA) { 173 } else if (!ok && GetLastError() != ERROR_NO_DATA) {
179 FATAL1("Failed to write exit code: %d", GetLastError()); 174 FATAL1("Failed to write exit code: %d", GetLastError());
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 841
847 842
848 intptr_t Process::CurrentProcessId() { 843 intptr_t Process::CurrentProcessId() {
849 return static_cast<intptr_t>(GetCurrentProcessId()); 844 return static_cast<intptr_t>(GetCurrentProcessId());
850 } 845 }
851 846
852 } // namespace bin 847 } // namespace bin
853 } // namespace dart 848 } // namespace dart
854 849
855 #endif // defined(TARGET_OS_WINDOWS) 850 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698