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() { | |
19 return getpid(); | |
20 } | |
21 | |
22 ProcessHandle GetCurrentProcessHandle() { | |
23 return GetCurrentProcId(); | |
24 } | |
25 | |
26 void RaiseProcessToHighPriority() { | 18 void RaiseProcessToHighPriority() { |
27 // Impossible on iOS. Do nothing. | 19 // Impossible on iOS. Do nothing. |
28 } | 20 } |
29 | 21 |
30 size_t GetMaxFds() { | |
31 static const rlim_t kSystemDefaultMaxFds = 256; | |
32 rlim_t max_fds; | |
33 struct rlimit nofile; | |
34 if (getrlimit(RLIMIT_NOFILE, &nofile)) { | |
35 // Error case: Take a best guess. | |
36 max_fds = kSystemDefaultMaxFds; | |
37 } else { | |
38 max_fds = nofile.rlim_cur; | |
39 } | |
40 | |
41 if (max_fds > INT_MAX) | |
42 max_fds = INT_MAX; | |
43 | |
44 return static_cast<size_t>(max_fds); | |
45 } | |
46 | |
47 } // namespace base | 22 } // namespace base |
OLD | NEW |