| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // bionic/libc/bionic/ndk_cruft.cpp getdtablesize(). | 172 // bionic/libc/bionic/ndk_cruft.cpp getdtablesize(). |
| 173 int max_fd = implicit_cast<int>(sysconf(_SC_OPEN_MAX)); | 173 int max_fd = implicit_cast<int>(sysconf(_SC_OPEN_MAX)); |
| 174 | 174 |
| 175 #if !defined(OS_ANDROID) | 175 #if !defined(OS_ANDROID) |
| 176 // getdtablesize() was removed effective Android 5.0.0 (API 21). Since it | 176 // getdtablesize() was removed effective Android 5.0.0 (API 21). Since it |
| 177 // returns the same thing as the sysconf() above, just skip it. See | 177 // returns the same thing as the sysconf() above, just skip it. See |
| 178 // https://android.googlesource.com/platform/bionic/+/462abab12b074c62c0999859
e65d5a32ebb41951. | 178 // https://android.googlesource.com/platform/bionic/+/462abab12b074c62c0999859
e65d5a32ebb41951. |
| 179 max_fd = std::max(max_fd, getdtablesize()); | 179 max_fd = std::max(max_fd, getdtablesize()); |
| 180 #endif | 180 #endif |
| 181 | 181 |
| 182 #if !defined(OS_LINUX) || defined(OPEN_MAX) | 182 #if !(defined(OS_LINUX) || defined(OS_ANDROID)) || defined(OPEN_MAX) |
| 183 // Linux does not provide OPEN_MAX. See | 183 // Linux does not provide OPEN_MAX. See |
| 184 // https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit
/include/linux/limits.h?id=77293034696e3e0b6c8b8fc1f96be091104b3d2b. | 184 // https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit
/include/linux/limits.h?id=77293034696e3e0b6c8b8fc1f96be091104b3d2b. |
| 185 max_fd = std::max(max_fd, OPEN_MAX); | 185 max_fd = std::max(max_fd, OPEN_MAX); |
| 186 #endif | 186 #endif |
| 187 | 187 |
| 188 // Consult a sysctl to determine the system-wide limit on the maximum number | 188 // Consult a sysctl to determine the system-wide limit on the maximum number |
| 189 // of open files per process. Note that it is possible to change this limit | 189 // of open files per process. Note that it is possible to change this limit |
| 190 // while the system is running, but it’s still a better upper bound than the | 190 // while the system is running, but it’s still a better upper bound than the |
| 191 // current RLIMIT_NOFILE value. | 191 // current RLIMIT_NOFILE value. |
| 192 | 192 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 #endif | 225 #endif |
| 226 | 226 |
| 227 for (int entry_fd = fd; entry_fd < max_fd; ++entry_fd) { | 227 for (int entry_fd = fd; entry_fd < max_fd; ++entry_fd) { |
| 228 if (entry_fd != preserve_fd) { | 228 if (entry_fd != preserve_fd) { |
| 229 CloseNowOrOnExec(entry_fd, true); | 229 CloseNowOrOnExec(entry_fd, true); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace crashpad | 234 } // namespace crashpad |
| OLD | NEW |