OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Returns the path to the executable of the given process. | 168 // Returns the path to the executable of the given process. |
169 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); | 169 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process); |
170 | 170 |
171 // Parse the data found in /proc/<pid>/stat and return the sum of the | 171 // Parse the data found in /proc/<pid>/stat and return the sum of the |
172 // CPU-related ticks. Returns -1 on parse error. | 172 // CPU-related ticks. Returns -1 on parse error. |
173 // Exposed for testing. | 173 // Exposed for testing. |
174 BASE_EXPORT int ParseProcStatCPU(const std::string& input); | 174 BASE_EXPORT int ParseProcStatCPU(const std::string& input); |
175 | 175 |
176 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; | 176 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; |
177 | 177 |
178 // This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer | 178 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will |
179 // certain process types over others. The range for the adjustment is | 179 // prefer to kill certain process types over others. The range for the |
180 // [-17,15], with [0,15] being user accessible. | 180 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. |
| 181 // If the Linux system doesn't support the newer oom_score_adj range |
| 182 // of [0, 1000], then we revert to using the older oom_adj, and |
| 183 // translate the given value into [0, 15]. Some aliasing of values |
| 184 // may occur in that case, of course. |
181 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); | 185 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); |
182 #endif | 186 #endif |
183 | 187 |
184 #if defined(OS_POSIX) | 188 #if defined(OS_POSIX) |
185 // Returns the ID for the parent of the given process. | 189 // Returns the ID for the parent of the given process. |
186 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); | 190 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); |
187 | 191 |
188 // Close all file descriptors, except those which are a destination in the | 192 // Close all file descriptors, except those which are a destination in the |
189 // given multimap. Only call this function in a child process where you know | 193 // given multimap. Only call this function in a child process where you know |
190 // that there aren't any other threads. | 194 // that there aren't any other threads. |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // instance running inside the parent. The parent's Breakpad instance should | 722 // instance running inside the parent. The parent's Breakpad instance should |
719 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 723 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
720 // in the child after forking will restore the standard exception handler. | 724 // in the child after forking will restore the standard exception handler. |
721 // See http://crbug.com/20371/ for more details. | 725 // See http://crbug.com/20371/ for more details. |
722 void RestoreDefaultExceptionHandler(); | 726 void RestoreDefaultExceptionHandler(); |
723 #endif // defined(OS_MACOSX) | 727 #endif // defined(OS_MACOSX) |
724 | 728 |
725 } // namespace base | 729 } // namespace base |
726 | 730 |
727 #endif // BASE_PROCESS_UTIL_H_ | 731 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |