| Index: base/process_util_posix.cc
|
| diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
|
| index 3153a59aa0fce1c877cceb3754b680523a8aa79e..2cfa6f9a4c2ca000cd5839abfbda8d285694d650 100644
|
| --- a/base/process_util_posix.cc
|
| +++ b/base/process_util_posix.cc
|
| @@ -9,6 +9,7 @@
|
| #include <sys/types.h>
|
| #include <sys/wait.h>
|
| #include <unistd.h>
|
| +#include <limits>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/logging.h"
|
| @@ -31,6 +32,23 @@ int GetProcId(ProcessHandle process) {
|
| return process;
|
| }
|
|
|
| +int GetMaxFilesOpenInProcess() {
|
| + struct rlimit rlimit;
|
| + if (getrlimit(RLIMIT_NOFILE, &rlimit) != 0) {
|
| + return 0;
|
| + }
|
| +
|
| + // rlim_t is a uint64 - clip to maxint.
|
| + // We do this since we use the value of this function to close FD #s in a loop
|
| + // if we didn't clamp the value, doing this would be too time consuming.
|
| + rlim_t max_int = static_cast<rlim_t>(std::numeric_limits<int32>::max());
|
| + if (rlimit.rlim_cur > max_int) {
|
| + return max_int;
|
| + }
|
| +
|
| + return rlimit.rlim_cur;
|
| +}
|
| +
|
| ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process),
|
| last_time_(0),
|
| last_system_time_(0) {
|
|
|