| Index: base/process_util_linux.cc
|
| ===================================================================
|
| --- base/process_util_linux.cc (revision 34180)
|
| +++ base/process_util_linux.cc (working copy)
|
| @@ -513,7 +513,6 @@
|
| } // namespace
|
|
|
| extern "C" {
|
| -
|
| #if !defined(LINUX_USE_TCMALLOC)
|
|
|
| typedef void* (*malloc_type)(size_t size);
|
| @@ -600,7 +599,6 @@
|
| }
|
|
|
| #endif // !defined(LINUX_USE_TCMALLOC)
|
| -
|
| } // extern C
|
|
|
| void EnableTerminationOnOutOfMemory() {
|
| @@ -610,4 +608,20 @@
|
| // malloc and friends and make them die on out of memory.
|
| }
|
|
|
| +bool AdjustOOMScore(ProcessId process, int score) {
|
| + if (score < 0 || score > 15)
|
| + return false;
|
| +
|
| + FilePath oom_adj("/proc");
|
| + oom_adj = oom_adj.Append(Int64ToString(process));
|
| + oom_adj = oom_adj.AppendASCII("oom_adj");
|
| +
|
| + if (!file_util::PathExists(oom_adj))
|
| + return false;
|
| +
|
| + std::string score_str = IntToString(score);
|
| + return (static_cast<int>(score_str.length()) ==
|
| + file_util::WriteFile(oom_adj, score_str.c_str(), score_str.length()));
|
| +}
|
| +
|
| } // namespace base
|
|
|