| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 if (exit_code < 0) { | 218 if (exit_code < 0) { |
| 219 exit_code = abs(exit_code); | 219 exit_code = abs(exit_code); |
| 220 negative = 1; | 220 negative = 1; |
| 221 } | 221 } |
| 222 int message[3] = { process->pid(), exit_code, negative }; | 222 int message[3] = { process->pid(), exit_code, negative }; |
| 223 DWORD written; | 223 DWORD written; |
| 224 ok = WriteFile( | 224 ok = WriteFile( |
| 225 process->exit_pipe(), message, sizeof(message), &written, NULL); | 225 process->exit_pipe(), message, sizeof(message), &written, NULL); |
| 226 if (!ok || written != sizeof(message)) { | 226 if (!ok || written != sizeof(message)) { |
| 227 fprintf(stderr, "FileWrite failed %d\n", GetLastError()); | 227 fprintf(stderr, "WriteFile failed %d\n", GetLastError()); |
| 228 } | 228 } |
| 229 return 0; | 229 return 0; |
| 230 } | 230 } |
| 231 | 231 |
| 232 | 232 |
| 233 int Process::Start(const char* path, | 233 int Process::Start(const char* path, |
| 234 char* arguments[], | 234 char* arguments[], |
| 235 intptr_t arguments_length, | 235 intptr_t arguments_length, |
| 236 intptr_t* in, | 236 intptr_t* in, |
| 237 intptr_t* out, | 237 intptr_t* out, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 process_info.hProcess, | 368 process_info.hProcess, |
| 369 exit_handles[kWriteHandle]); | 369 exit_handles[kWriteHandle]); |
| 370 AddProcess(process); | 370 AddProcess(process); |
| 371 | 371 |
| 372 // TODO(sgjesse): Don't use a separate thread for waiting for each process to | 372 // TODO(sgjesse): Don't use a separate thread for waiting for each process to |
| 373 // terminate. | 373 // terminate. |
| 374 uint32_t tid; | 374 uint32_t tid; |
| 375 uintptr_t thread_handle = | 375 uintptr_t thread_handle = |
| 376 _beginthreadex(NULL, 32 * 1024, TerminationWaitThread, process, 0, &tid); | 376 _beginthreadex(NULL, 32 * 1024, TerminationWaitThread, process, 0, &tid); |
| 377 if (thread_handle == -1) { | 377 if (thread_handle == -1) { |
| 378 FATAL("Failed to start event handler thread"); | 378 FATAL("Failed to start process termination wait thread"); |
| 379 } | 379 } |
| 380 | 380 |
| 381 | |
| 382 // Connect the three std streams. | 381 // Connect the three std streams. |
| 383 FileHandle* stdin_handle = new FileHandle(stdin_handles[kWriteHandle]); | 382 FileHandle* stdin_handle = new FileHandle(stdin_handles[kWriteHandle]); |
| 384 CloseHandle(stdin_handles[kReadHandle]); | 383 CloseHandle(stdin_handles[kReadHandle]); |
| 385 FileHandle* stdout_handle = new FileHandle(stdout_handles[kReadHandle]); | 384 FileHandle* stdout_handle = new FileHandle(stdout_handles[kReadHandle]); |
| 386 CloseHandle(stdout_handles[kWriteHandle]); | 385 CloseHandle(stdout_handles[kWriteHandle]); |
| 387 FileHandle* stderr_handle = new FileHandle(stderr_handles[kReadHandle]); | 386 FileHandle* stderr_handle = new FileHandle(stderr_handles[kReadHandle]); |
| 388 CloseHandle(stderr_handles[kWriteHandle]); | 387 CloseHandle(stderr_handles[kWriteHandle]); |
| 389 FileHandle* exit_handle = new FileHandle(exit_handles[kReadHandle]); | 388 FileHandle* exit_handle = new FileHandle(exit_handles[kReadHandle]); |
| 390 *in = reinterpret_cast<intptr_t>(stdout_handle); | 389 *in = reinterpret_cast<intptr_t>(stdout_handle); |
| 391 *out = reinterpret_cast<intptr_t>(stdin_handle); | 390 *out = reinterpret_cast<intptr_t>(stdin_handle); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 409 return false; | 408 return false; |
| 410 } | 409 } |
| 411 } | 410 } |
| 412 return true; | 411 return true; |
| 413 } | 412 } |
| 414 | 413 |
| 415 | 414 |
| 416 void Process::Exit(intptr_t id) { | 415 void Process::Exit(intptr_t id) { |
| 417 RemoveProcess(id); | 416 RemoveProcess(id); |
| 418 } | 417 } |
| OLD | NEW |