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

Side by Side Diff: sandbox/linux/services/resource_limits.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sandbox/linux/services/resource_limits.h"
6
7 #include <sys/resource.h>
8 #include <sys/time.h>
9
10 #include <algorithm>
11
12 namespace sandbox {
13
14 // static
15 bool ResourceLimits::Lower(int resource, rlim_t limit) {
16 struct rlimit old_rlimit;
17 if (getrlimit(resource, &old_rlimit))
18 return false;
19 // Make sure we don't raise the existing limit.
20 const struct rlimit new_rlimit = {std::min(old_rlimit.rlim_cur, limit),
21 std::min(old_rlimit.rlim_max, limit)};
22 int rc = setrlimit(resource, &new_rlimit);
23 return rc == 0;
24 }
25
26 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/resource_limits.h ('k') | sandbox/linux/services/resource_limits_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698