| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <dirent.h> | 5 #include <dirent.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 memcpy(scratch, j->second.c_str(), j->second.size() + 1); | 521 memcpy(scratch, j->second.c_str(), j->second.size() + 1); |
| 522 scratch += j->second.size() + 1; | 522 scratch += j->second.size() + 1; |
| 523 } | 523 } |
| 524 } | 524 } |
| 525 | 525 |
| 526 ret[k] = NULL; | 526 ret[k] = NULL; |
| 527 return ret; | 527 return ret; |
| 528 } | 528 } |
| 529 | 529 |
| 530 bool LaunchProcess(const std::vector<std::string>& argv, | 530 bool LaunchProcess(const std::vector<std::string>& argv, |
| 531 const LaunchOptions& options) { | 531 const LaunchOptions& options, |
| 532 ProcessHandle* process_handle) { |
| 532 pid_t pid; | 533 pid_t pid; |
| 533 InjectiveMultimap fd_shuffle1, fd_shuffle2; | 534 InjectiveMultimap fd_shuffle1, fd_shuffle2; |
| 534 if (options.fds_to_remap) { | 535 if (options.fds_to_remap) { |
| 535 fd_shuffle1.reserve(options.fds_to_remap->size()); | 536 fd_shuffle1.reserve(options.fds_to_remap->size()); |
| 536 fd_shuffle2.reserve(options.fds_to_remap->size()); | 537 fd_shuffle2.reserve(options.fds_to_remap->size()); |
| 537 } | 538 } |
| 538 scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); | 539 scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); |
| 539 scoped_array<char*> new_environ; | 540 scoped_array<char*> new_environ; |
| 540 if (options.environ) | 541 if (options.environ) |
| 541 new_environ.reset(AlterEnvironment(*options.environ, GetEnvironment())); | 542 new_environ.reset(AlterEnvironment(*options.environ, GetEnvironment())); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 } else { | 625 } else { |
| 625 // Parent process | 626 // Parent process |
| 626 if (options.wait) { | 627 if (options.wait) { |
| 627 // While this isn't strictly disk IO, waiting for another process to | 628 // While this isn't strictly disk IO, waiting for another process to |
| 628 // finish is the sort of thing ThreadRestrictions is trying to prevent. | 629 // finish is the sort of thing ThreadRestrictions is trying to prevent. |
| 629 base::ThreadRestrictions::AssertIOAllowed(); | 630 base::ThreadRestrictions::AssertIOAllowed(); |
| 630 pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0)); | 631 pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0)); |
| 631 DPCHECK(ret > 0); | 632 DPCHECK(ret > 0); |
| 632 } | 633 } |
| 633 | 634 |
| 634 if (options.process_handle) | 635 if (process_handle) |
| 635 *options.process_handle = pid; | 636 *process_handle = pid; |
| 636 } | 637 } |
| 637 | 638 |
| 638 return true; | 639 return true; |
| 639 } | 640 } |
| 640 | 641 |
| 641 bool LaunchProcess(const CommandLine& cmdline, | 642 bool LaunchProcess(const CommandLine& cmdline, |
| 642 const LaunchOptions& options) { | 643 const LaunchOptions& options, |
| 643 return LaunchProcess(cmdline.argv(), options); | 644 ProcessHandle* process_handle) { |
| 645 return LaunchProcess(cmdline.argv(), options, process_handle); |
| 644 } | 646 } |
| 645 | 647 |
| 646 ProcessMetrics::~ProcessMetrics() { } | 648 ProcessMetrics::~ProcessMetrics() { } |
| 647 | 649 |
| 648 void EnableTerminationOnHeapCorruption() { | 650 void EnableTerminationOnHeapCorruption() { |
| 649 // On POSIX, there nothing to do AFAIK. | 651 // On POSIX, there nothing to do AFAIK. |
| 650 } | 652 } |
| 651 | 653 |
| 652 bool EnableInProcessStackDumping() { | 654 bool EnableInProcessStackDumping() { |
| 653 // When running in an application, our code typically expects SIGPIPE | 655 // When running in an application, our code typically expects SIGPIPE |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 const ProcessFilter* filter) { | 1048 const ProcessFilter* filter) { |
| 1047 bool exited_cleanly = | 1049 bool exited_cleanly = |
| 1048 WaitForProcessesToExit(executable_name, wait_milliseconds, | 1050 WaitForProcessesToExit(executable_name, wait_milliseconds, |
| 1049 filter); | 1051 filter); |
| 1050 if (!exited_cleanly) | 1052 if (!exited_cleanly) |
| 1051 KillProcesses(executable_name, exit_code, filter); | 1053 KillProcesses(executable_name, exit_code, filter); |
| 1052 return exited_cleanly; | 1054 return exited_cleanly; |
| 1053 } | 1055 } |
| 1054 | 1056 |
| 1055 } // namespace base | 1057 } // namespace base |
| OLD | NEW |