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 #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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code); | 197 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code); |
198 } | 198 } |
199 os_error_message[os_error_message_len - 1] = '\0'; | 199 os_error_message[os_error_message_len - 1] = '\0'; |
200 return error_code; | 200 return error_code; |
201 } | 201 } |
202 | 202 |
203 | 203 |
204 static unsigned int __stdcall TerminationWaitThread(void* args) { | 204 static unsigned int __stdcall TerminationWaitThread(void* args) { |
205 ProcessInfo* process = reinterpret_cast<ProcessInfo*>(args); | 205 ProcessInfo* process = reinterpret_cast<ProcessInfo*>(args); |
206 WaitForSingleObject(process->process_handle(), INFINITE); | 206 WaitForSingleObject(process->process_handle(), INFINITE); |
207 DWORD exit_code; | 207 int exit_code; |
208 BOOL ok = GetExitCodeProcess(process->process_handle(), &exit_code); | 208 BOOL ok = GetExitCodeProcess(process->process_handle(), |
| 209 reinterpret_cast<DWORD*>(&exit_code)); |
209 if (!ok) { | 210 if (!ok) { |
210 fprintf(stderr, "GetExitCodeProcess failed %d\n", GetLastError()); | 211 fprintf(stderr, "GetExitCodeProcess failed %d\n", GetLastError()); |
211 } | 212 } |
212 intptr_t message[2] = { process->pid(), static_cast<intptr_t>(exit_code) }; | 213 int negative = 0; |
| 214 if (exit_code == 255) { |
| 215 exit_code = 1; |
| 216 negative = 1; |
| 217 } |
| 218 if (exit_code < 0) { |
| 219 exit_code = abs(exit_code); |
| 220 negative = 1; |
| 221 } |
| 222 int message[3] = { process->pid(), exit_code, negative }; |
213 DWORD written; | 223 DWORD written; |
214 ok = WriteFile( | 224 ok = WriteFile( |
215 process->exit_pipe(), message, sizeof(message), &written, NULL); | 225 process->exit_pipe(), message, sizeof(message), &written, NULL); |
216 if (!ok || written != 8) { | 226 if (!ok || written != sizeof(message)) { |
217 fprintf(stderr, "FileWrite failed %d\n", GetLastError()); | 227 fprintf(stderr, "FileWrite failed %d\n", GetLastError()); |
218 } | 228 } |
219 return 0; | 229 return 0; |
220 } | 230 } |
221 | 231 |
222 | 232 |
223 int Process::Start(const char* path, | 233 int Process::Start(const char* path, |
224 char* arguments[], | 234 char* arguments[], |
225 intptr_t arguments_length, | 235 intptr_t arguments_length, |
226 intptr_t* in, | 236 intptr_t* in, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 return false; | 409 return false; |
400 } | 410 } |
401 } | 411 } |
402 return true; | 412 return true; |
403 } | 413 } |
404 | 414 |
405 | 415 |
406 void Process::Exit(intptr_t id) { | 416 void Process::Exit(intptr_t id) { |
407 RemoveProcess(id); | 417 RemoveProcess(id); |
408 } | 418 } |
OLD | NEW |