| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process_util.h" | 5 #include "base/process_util.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 | 12 |
| 13 // This is just enough of a shim to let the support needed by test_support | 13 // This is just enough of a shim to let the support needed by test_support |
| 14 // link. In general, process_util isn't valid on iOS. | 14 // link. In general, process_util isn't valid on iOS. |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 | 17 |
| 18 ProcessId GetCurrentProcId() { | 18 ProcessId GetCurrentProcId() { |
| 19 return getpid(); | 19 return getpid(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ProcessHandle GetCurrentProcessHandle() { | 22 ProcessHandle GetCurrentProcessHandle() { |
| 23 return GetCurrentProcId(); | 23 return GetCurrentProcId(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void EnableTerminationOnHeapCorruption() { | |
| 27 // On iOS, there nothing to do AFAIK. | |
| 28 } | |
| 29 | |
| 30 void EnableTerminationOnOutOfMemory() { | |
| 31 // iOS provides this for free! | |
| 32 } | |
| 33 | |
| 34 void RaiseProcessToHighPriority() { | 26 void RaiseProcessToHighPriority() { |
| 35 // Impossible on iOS. Do nothing. | 27 // Impossible on iOS. Do nothing. |
| 36 } | 28 } |
| 37 | 29 |
| 38 size_t GetMaxFds() { | 30 size_t GetMaxFds() { |
| 39 static const rlim_t kSystemDefaultMaxFds = 256; | 31 static const rlim_t kSystemDefaultMaxFds = 256; |
| 40 rlim_t max_fds; | 32 rlim_t max_fds; |
| 41 struct rlimit nofile; | 33 struct rlimit nofile; |
| 42 if (getrlimit(RLIMIT_NOFILE, &nofile)) { | 34 if (getrlimit(RLIMIT_NOFILE, &nofile)) { |
| 43 // Error case: Take a best guess. | 35 // Error case: Take a best guess. |
| 44 max_fds = kSystemDefaultMaxFds; | 36 max_fds = kSystemDefaultMaxFds; |
| 45 } else { | 37 } else { |
| 46 max_fds = nofile.rlim_cur; | 38 max_fds = nofile.rlim_cur; |
| 47 } | 39 } |
| 48 | 40 |
| 49 if (max_fds > INT_MAX) | 41 if (max_fds > INT_MAX) |
| 50 max_fds = INT_MAX; | 42 max_fds = INT_MAX; |
| 51 | 43 |
| 52 return static_cast<size_t>(max_fds); | 44 return static_cast<size_t>(max_fds); |
| 53 } | 45 } |
| 54 | 46 |
| 55 } // namespace base | 47 } // namespace base |
| OLD | NEW |