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

Side by Side Diff: bin/process_win.cc

Issue 8277035: Get the OS error message for process exceptions on Windows (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years, 2 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 | « 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) 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 #include <process.h> 5 #include <process.h>
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/globals.h" 8 #include "bin/globals.h"
9 #include "bin/process.h" 9 #include "bin/process.h"
10 #include "bin/eventhandler.h" 10 #include "bin/eventhandler.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 HANDLE handles2[2], 173 HANDLE handles2[2],
174 HANDLE handles3[2], 174 HANDLE handles3[2],
175 HANDLE handles4[2]) { 175 HANDLE handles4[2]) {
176 CloseProcessPipe(handles1); 176 CloseProcessPipe(handles1);
177 CloseProcessPipe(handles2); 177 CloseProcessPipe(handles2);
178 CloseProcessPipe(handles3); 178 CloseProcessPipe(handles3);
179 CloseProcessPipe(handles4); 179 CloseProcessPipe(handles4);
180 } 180 }
181 181
182 static int SetOsErrorMessage(char* os_error_message, 182 static int SetOsErrorMessage(char* os_error_message,
183 int os_error_message_len) { 183 int os_error_message_len) {
184 int error_code = GetLastError(); 184 int error_code = GetLastError();
185 // TODO(sgjesse): Use FormatMessage to get the error message. 185 DWORD message_size =
186 char message[80]; 186 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
187 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code); 187 NULL,
188 error_code,
189 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
190 os_error_message,
191 os_error_message_len,
192 NULL);
193 if (message_size == 0) {
194 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
195 fprintf(stderr, "FormatMessage failed %d\n", GetLastError());
196 }
197 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code);
198 }
199 os_error_message[os_error_message_len - 1] = '\0';
188 return error_code; 200 return error_code;
189 } 201 }
190 202
191 203
192 static unsigned int __stdcall TerminationWaitThread(void* args) { 204 static unsigned int __stdcall TerminationWaitThread(void* args) {
193 ProcessInfo* process = reinterpret_cast<ProcessInfo*>(args); 205 ProcessInfo* process = reinterpret_cast<ProcessInfo*>(args);
194 WaitForSingleObject(process->process_handle(), INFINITE); 206 WaitForSingleObject(process->process_handle(), INFINITE);
195 DWORD exit_code; 207 DWORD exit_code;
196 BOOL ok = GetExitCodeProcess(process->process_handle(), &exit_code); 208 BOOL ok = GetExitCodeProcess(process->process_handle(), &exit_code);
197 if (!ok) { 209 if (!ok) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return false; 399 return false;
388 } 400 }
389 } 401 }
390 return true; 402 return true;
391 } 403 }
392 404
393 405
394 void Process::Exit(intptr_t id) { 406 void Process::Exit(intptr_t id) {
395 RemoveProcess(id); 407 RemoveProcess(id);
396 } 408 }
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