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

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

Issue 11474053: Revert update of stable test binary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | tools/testing/bin/linux/dart » ('j') | 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 <process.h> 5 #include <process.h>
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/process.h" 8 #include "bin/process.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/log.h" 10 #include "bin/log.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return error_code; 382 return error_code;
383 } 383 }
384 if (!CreateProcessPipe(exit_handles, pipe_names[3], kInheritNone)) { 384 if (!CreateProcessPipe(exit_handles, pipe_names[3], kInheritNone)) {
385 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len); 385 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
386 CloseProcessPipes( 386 CloseProcessPipes(
387 stdin_handles, stdout_handles, stderr_handles, exit_handles); 387 stdin_handles, stdout_handles, stderr_handles, exit_handles);
388 return error_code; 388 return error_code;
389 } 389 }
390 390
391 // Setup info structures. 391 // Setup info structures.
392 STARTUPINFOEX startup_info; 392 STARTUPINFO startup_info;
393 ZeroMemory(&startup_info, sizeof(startup_info)); 393 ZeroMemory(&startup_info, sizeof(startup_info));
394 startup_info.StartupInfo.cb = sizeof(startup_info); 394 startup_info.cb = sizeof(startup_info);
395 startup_info.StartupInfo.hStdInput = stdin_handles[kReadHandle]; 395 startup_info.hStdInput = stdin_handles[kReadHandle];
396 startup_info.StartupInfo.hStdOutput = stdout_handles[kWriteHandle]; 396 startup_info.hStdOutput = stdout_handles[kWriteHandle];
397 startup_info.StartupInfo.hStdError = stderr_handles[kWriteHandle]; 397 startup_info.hStdError = stderr_handles[kWriteHandle];
398 startup_info.StartupInfo.dwFlags = STARTF_USESTDHANDLES; 398 startup_info.dwFlags = STARTF_USESTDHANDLES;
399
400 // Setup the handles to inherit. We only want to inherit the three handles
401 // for stdin, stdout and stderr.
402 SIZE_T size = 0;
403 // The call to determine the size of an attribute list always fails with
404 // ERROR_INSUFFICIENT_BUFFER and that error should be ignored.
405 if (!InitializeProcThreadAttributeList(NULL, 1, 0, &size) &&
406 GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
407 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
408 CloseProcessPipes(
409 stdin_handles, stdout_handles, stderr_handles, exit_handles);
410 return error_code;
411 }
412 LPPROC_THREAD_ATTRIBUTE_LIST attribute_list =
413 reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(malloc(size));
414 ZeroMemory(attribute_list, size);
415 if (!InitializeProcThreadAttributeList(attribute_list, 1, 0, &size)) {
416 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
417 CloseProcessPipes(
418 stdin_handles, stdout_handles, stderr_handles, exit_handles);
419 free(attribute_list);
420 return error_code;
421 }
422 static const int kNumInheritedHandles = 3;
423 HANDLE inherited_handles[kNumInheritedHandles] =
424 { stdin_handles[kReadHandle],
425 stdout_handles[kWriteHandle],
426 stderr_handles[kWriteHandle] };
427 if (!UpdateProcThreadAttribute(attribute_list,
428 0,
429 PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
430 inherited_handles,
431 kNumInheritedHandles * sizeof(HANDLE),
432 NULL,
433 NULL)) {
434 DeleteProcThreadAttributeList(attribute_list);
435 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
436 CloseProcessPipes(
437 stdin_handles, stdout_handles, stderr_handles, exit_handles);
438 free(attribute_list);
439 return error_code;
440 }
441 startup_info.lpAttributeList = attribute_list;
442 399
443 PROCESS_INFORMATION process_info; 400 PROCESS_INFORMATION process_info;
444 ZeroMemory(&process_info, sizeof(process_info)); 401 ZeroMemory(&process_info, sizeof(process_info));
445 402
446 // Transform input strings to system format. 403 // Transform input strings to system format.
447 path = StringUtils::Utf8ToSystemString(path); 404 path = StringUtils::Utf8ToSystemString(path);
448 for (int i = 0; i < arguments_length; i++) { 405 for (int i = 0; i < arguments_length; i++) {
449 arguments[i] = StringUtils::Utf8ToSystemString(arguments[i]); 406 arguments[i] = StringUtils::Utf8ToSystemString(arguments[i]);
450 } 407 }
451 408
452 // Compute command-line length. 409 // Compute command-line length.
453 int command_line_length = strlen(path); 410 int command_line_length = strlen(path);
454 for (int i = 0; i < arguments_length; i++) { 411 for (int i = 0; i < arguments_length; i++) {
455 command_line_length += strlen(arguments[i]); 412 command_line_length += strlen(arguments[i]);
456 } 413 }
457 // Account for null termination and one space per argument. 414 // Account for null termination and one space per argument.
458 command_line_length += arguments_length + 1; 415 command_line_length += arguments_length + 1;
459 static const int kMaxCommandLineLength = 32768; 416 static const int kMaxCommandLineLength = 32768;
460 if (command_line_length > kMaxCommandLineLength) { 417 if (command_line_length > kMaxCommandLineLength) {
461 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len); 418 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
462 CloseProcessPipes( 419 CloseProcessPipes(
463 stdin_handles, stdout_handles, stderr_handles, exit_handles); 420 stdin_handles, stdout_handles, stderr_handles, exit_handles);
464 free(const_cast<char*>(path)); 421 free(const_cast<char*>(path));
465 for (int i = 0; i < arguments_length; i++) free(arguments[i]); 422 for (int i = 0; i < arguments_length; i++) free(arguments[i]);
466 DeleteProcThreadAttributeList(attribute_list);
467 free(attribute_list);
468 return error_code; 423 return error_code;
469 } 424 }
470 425
471 // Put together command-line string. 426 // Put together command-line string.
472 char* command_line = new char[command_line_length]; 427 char* command_line = new char[command_line_length];
473 int len = 0; 428 int len = 0;
474 int remaining = command_line_length; 429 int remaining = command_line_length;
475 int written = snprintf(command_line + len, remaining, "%s", path); 430 int written = snprintf(command_line + len, remaining, "%s", path);
476 len += written; 431 len += written;
477 remaining -= written; 432 remaining -= written;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (working_directory != NULL) { 475 if (working_directory != NULL) {
521 working_directory = StringUtils::Utf8ToSystemString(working_directory); 476 working_directory = StringUtils::Utf8ToSystemString(working_directory);
522 } 477 }
523 478
524 // Create process. 479 // Create process.
525 BOOL result = CreateProcess(NULL, // ApplicationName 480 BOOL result = CreateProcess(NULL, // ApplicationName
526 command_line, 481 command_line,
527 NULL, // ProcessAttributes 482 NULL, // ProcessAttributes
528 NULL, // ThreadAttributes 483 NULL, // ThreadAttributes
529 TRUE, // InheritHandles 484 TRUE, // InheritHandles
530 EXTENDED_STARTUPINFO_PRESENT, 485 0, // CreationFlags
531 environment_block, 486 environment_block,
532 working_directory, 487 working_directory,
533 reinterpret_cast<STARTUPINFO*>(&startup_info), 488 &startup_info,
534 &process_info); 489 &process_info);
535 490
536 // Deallocate command-line and environment block strings. 491 // Deallocate command-line and environment block strings.
537 delete[] command_line; 492 delete[] command_line;
538 delete[] environment_block; 493 delete[] environment_block;
539 if (working_directory != NULL) { 494 if (working_directory != NULL) {
540 free(const_cast<char*>(working_directory)); 495 free(const_cast<char*>(working_directory));
541 } 496 }
542 497
543 DeleteProcThreadAttributeList(attribute_list);
544 free(attribute_list);
545
546 if (result == 0) { 498 if (result == 0) {
547 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len); 499 int error_code = SetOsErrorMessage(os_error_message, os_error_message_len);
548 CloseProcessPipes( 500 CloseProcessPipes(
549 stdin_handles, stdout_handles, stderr_handles, exit_handles); 501 stdin_handles, stdout_handles, stderr_handles, exit_handles);
550 return error_code; 502 return error_code;
551 } 503 }
552 504
553 ProcessInfoList::AddProcess(process_info.dwProcessId, 505 ProcessInfoList::AddProcess(process_info.dwProcessId,
554 process_info.hProcess, 506 process_info.hProcess,
555 exit_handles[kWriteHandle]); 507 exit_handles[kWriteHandle]);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 544
593 545
594 void Process::TerminateExitCodeHandler() { 546 void Process::TerminateExitCodeHandler() {
595 // Nothing needs to be done on Windows. 547 // Nothing needs to be done on Windows.
596 } 548 }
597 549
598 550
599 intptr_t Process::CurrentProcessId() { 551 intptr_t Process::CurrentProcessId() {
600 return static_cast<intptr_t>(GetCurrentProcessId()); 552 return static_cast<intptr_t>(GetCurrentProcessId());
601 } 553 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/bin/linux/dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698