Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/time.h> | |
| 8 #include <sys/resource.h> | |
|
Mark Seaborn
2015/02/13 17:11:54
Nit: sort #includes
jln (very slow on Chromium)
2015/02/13 18:00:05
Done.
| |
| 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 | |
| OLD | NEW |