Commit 7049bab8 authored by mattm@chromium.org's avatar mattm@chromium.org

posix LaunchProcess: remove more iterator usage that was missed in r243401

BUG=331459
TBR=sehr@chromium.org

Review URL: https://codereview.chromium.org/126823003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243720 0039d316-1c4b-4281-b951-d872f2087c98
parent 1f8d8ac4
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#ifndef BASE_PROCESS_LAUNCH_H_ #ifndef BASE_PROCESS_LAUNCH_H_
#define BASE_PROCESS_LAUNCH_H_ #define BASE_PROCESS_LAUNCH_H_
#include <set>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -102,7 +101,7 @@ struct BASE_EXPORT LaunchOptions { ...@@ -102,7 +101,7 @@ struct BASE_EXPORT LaunchOptions {
// Each element is an RLIMIT_* constant that should be raised to its // Each element is an RLIMIT_* constant that should be raised to its
// rlim_max. This pointer is owned by the caller and must live through // rlim_max. This pointer is owned by the caller and must live through
// the call to LaunchProcess(). // the call to LaunchProcess().
const std::set<int>* maximize_rlimits; const std::vector<int>* maximize_rlimits;
// If true, start the process in a new process group, instead of // If true, start the process in a new process group, instead of
// inheriting the parent's process group. The pgid of the child process // inheriting the parent's process group. The pgid of the child process
......
...@@ -320,6 +320,9 @@ bool LaunchProcess(const std::vector<std::string>& argv, ...@@ -320,6 +320,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
} else if (pid == 0) { } else if (pid == 0) {
// Child process // Child process
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
// DANGER: fork() rule: in the child, if you don't end up doing exec*(), // DANGER: fork() rule: in the child, if you don't end up doing exec*(),
// you call _exit() instead of exit(). This is because _exit() does not // you call _exit() instead of exit(). This is because _exit() does not
// call any previously-registered (in the parent) exit handlers, which // call any previously-registered (in the parent) exit handlers, which
...@@ -358,16 +361,14 @@ bool LaunchProcess(const std::vector<std::string>& argv, ...@@ -358,16 +361,14 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (options.maximize_rlimits) { if (options.maximize_rlimits) {
// Some resource limits need to be maximal in this child. // Some resource limits need to be maximal in this child.
std::set<int>::const_iterator resource; for (size_t i = 0; i < options.maximize_rlimits->size(); ++i) {
for (resource = options.maximize_rlimits->begin(); const int resource = (*options.maximize_rlimits)[i];
resource != options.maximize_rlimits->end();
++resource) {
struct rlimit limit; struct rlimit limit;
if (getrlimit(*resource, &limit) < 0) { if (getrlimit(resource, &limit) < 0) {
RAW_LOG(WARNING, "getrlimit failed"); RAW_LOG(WARNING, "getrlimit failed");
} else if (limit.rlim_cur < limit.rlim_max) { } else if (limit.rlim_cur < limit.rlim_max) {
limit.rlim_cur = limit.rlim_max; limit.rlim_cur = limit.rlim_max;
if (setrlimit(*resource, &limit) < 0) { if (setrlimit(resource, &limit) < 0) {
RAW_LOG(WARNING, "setrlimit failed"); RAW_LOG(WARNING, "setrlimit failed");
} }
} }
...@@ -390,9 +391,6 @@ bool LaunchProcess(const std::vector<std::string>& argv, ...@@ -390,9 +391,6 @@ bool LaunchProcess(const std::vector<std::string>& argv,
memset(reinterpret_cast<void*>(malloc), 0xff, 8); memset(reinterpret_cast<void*>(malloc), 0xff, 8);
#endif // 0 #endif // 0
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (options.ctrl_terminal_fd >= 0) { if (options.ctrl_terminal_fd >= 0) {
// Set process' controlling terminal. // Set process' controlling terminal.
...@@ -521,11 +519,12 @@ static GetAppOutputInternalResult GetAppOutputInternal( ...@@ -521,11 +519,12 @@ static GetAppOutputInternalResult GetAppOutputInternal(
return EXECUTE_FAILURE; return EXECUTE_FAILURE;
case 0: // child case 0: // child
{ {
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
RestoreDefaultExceptionHandler(); RestoreDefaultExceptionHandler();
#endif #endif
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
// Obscure fork() rule: in the child, if you don't end up doing exec*(), // Obscure fork() rule: in the child, if you don't end up doing exec*(),
// you call _exit() instead of exit(). This is because _exit() does not // you call _exit() instead of exit(). This is because _exit() does not
...@@ -547,8 +546,8 @@ static GetAppOutputInternalResult GetAppOutputInternal( ...@@ -547,8 +546,8 @@ static GetAppOutputInternalResult GetAppOutputInternal(
// Adding another element here? Remeber to increase the argument to // Adding another element here? Remeber to increase the argument to
// reserve(), above. // reserve(), above.
std::copy(fd_shuffle1.begin(), fd_shuffle1.end(), for (size_t i = 0; i < fd_shuffle1.size(); ++i)
std::back_inserter(fd_shuffle2)); fd_shuffle2.push_back(fd_shuffle1[i]);
if (!ShuffleFileDescriptors(&fd_shuffle1)) if (!ShuffleFileDescriptors(&fd_shuffle1))
_exit(127); _exit(127);
......
...@@ -198,8 +198,8 @@ void NaClForkDelegate::Init(const int sandboxdesc) { ...@@ -198,8 +198,8 @@ void NaClForkDelegate::Init(const int sandboxdesc) {
// because the existing limit may prevent the initial exec of // because the existing limit may prevent the initial exec of
// nacl_helper_bootstrap from succeeding, with its large address space // nacl_helper_bootstrap from succeeding, with its large address space
// reservation. // reservation.
std::set<int> max_these_limits; std::vector<int> max_these_limits;
max_these_limits.insert(RLIMIT_AS); max_these_limits.push_back(RLIMIT_AS);
options.maximize_rlimits = &max_these_limits; options.maximize_rlimits = &max_these_limits;
if (!base::LaunchProcess(argv_to_launch, options, NULL)) if (!base::LaunchProcess(argv_to_launch, options, NULL))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment