// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // The following is the C version of code from base/process_utils_linux.cc. // We shouldn't link against C++ code in a setuid binary. // Needed for O_DIRECTORY, must be defined before fcntl.h is included // (and it can be included earlier than the explicit #include below // in some versions of glibc). #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include "sandbox/linux/suid/process_util.h" #include <fcntl.h> #include <inttypes.h> #include <limits.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> // Ranges for the current (oom_score_adj) and previous (oom_adj) // flavors of OOM score. static const int kMaxOomScore = …; static const int kMaxOldOomScore = …; // NOTE: This is not the only version of this function in the source: // the base library (in process_util_linux.cc) also has its own C++ version. bool AdjustOOMScore(pid_t process, int score) { … }