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 @@
#ifndef BASE_PROCESS_LAUNCH_H_
#define BASE_PROCESS_LAUNCH_H_
#include <set>
#include <string>
#include <utility>
#include <vector>
......@@ -102,7 +101,7 @@ struct BASE_EXPORT LaunchOptions {
// 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
// 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
// inheriting the parent's process group. The pgid of the child process
......
......@@ -320,6 +320,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
} else if (pid == 0) {
// 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*(),
// you call _exit() instead of exit(). This is because _exit() does not
// call any previously-registered (in the parent) exit handlers, which
......@@ -358,16 +361,14 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (options.maximize_rlimits) {
// Some resource limits need to be maximal in this child.
std::set<int>::const_iterator resource;
for (resource = options.maximize_rlimits->begin();
resource != options.maximize_rlimits->end();
++resource) {
for (size_t i = 0; i < options.maximize_rlimits->size(); ++i) {
const int resource = (*options.maximize_rlimits)[i];
struct rlimit limit;
if (getrlimit(*resource, &limit) < 0) {
if (getrlimit(resource, &limit) < 0) {
RAW_LOG(WARNING, "getrlimit failed");
} else if (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");
}
}
......@@ -390,9 +391,6 @@ bool LaunchProcess(const std::vector<std::string>& argv,
memset(reinterpret_cast<void*>(malloc), 0xff, 8);
#endif // 0
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
#if defined(OS_CHROMEOS)
if (options.ctrl_terminal_fd >= 0) {
// Set process' controlling terminal.
......@@ -521,11 +519,12 @@ static GetAppOutputInternalResult GetAppOutputInternal(
return EXECUTE_FAILURE;
case 0: // child
{
// DANGER: no calls to malloc or locks are allowed from now on:
// http://crbug.com/36678
#if defined(OS_MACOSX)
RestoreDefaultExceptionHandler();
#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*(),
// you call _exit() instead of exit(). This is because _exit() does not
......@@ -547,8 +546,8 @@ static GetAppOutputInternalResult GetAppOutputInternal(
// Adding another element here? Remeber to increase the argument to
// reserve(), above.
std::copy(fd_shuffle1.begin(), fd_shuffle1.end(),
std::back_inserter(fd_shuffle2));
for (size_t i = 0; i < fd_shuffle1.size(); ++i)
fd_shuffle2.push_back(fd_shuffle1[i]);
if (!ShuffleFileDescriptors(&fd_shuffle1))
_exit(127);
......
......@@ -198,8 +198,8 @@ void NaClForkDelegate::Init(const int sandboxdesc) {
// because the existing limit may prevent the initial exec of
// nacl_helper_bootstrap from succeeding, with its large address space
// reservation.
std::set<int> max_these_limits;
max_these_limits.insert(RLIMIT_AS);
std::vector<int> max_these_limits;
max_these_limits.push_back(RLIMIT_AS);
options.maximize_rlimits = &max_these_limits;
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