diff options
-rw-r--r-- | base/base_paths_android.cc | 11 | ||||
-rw-r--r-- | base/base_paths_posix.cc | 11 | ||||
-rw-r--r-- | base/process_util.h | 5 | ||||
-rw-r--r-- | base/process_util_linux.cc | 2 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_suite.cc | 5 | ||||
-rw-r--r-- | content/browser/browser_main_loop.cc | 4 | ||||
-rw-r--r-- | content/common/child_process_host_impl.cc | 2 | ||||
-rw-r--r-- | content/common/set_process_title.cc | 3 |
8 files changed, 23 insertions, 20 deletions
diff --git a/base/base_paths_android.cc b/base/base_paths_android.cc index 92d269a..f631c61 100644 --- a/base/base_paths_android.cc +++ b/base/base_paths_android.cc @@ -11,12 +11,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" - -namespace { - -const char kSelfExe[] = "/proc/self/exe"; - -} // namespace +#include "base/process_util.h" namespace base { @@ -24,9 +19,9 @@ bool PathProviderAndroid(int key, FilePath* result) { switch (key) { case base::FILE_EXE: { char bin_dir[PATH_MAX + 1]; - int bin_dir_size = readlink(kSelfExe, bin_dir, PATH_MAX); + int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX); if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { - NOTREACHED() << "Unable to resolve " << kSelfExe << "."; + NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; return false; } bin_dir[bin_dir_size] = 0; diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index 9be441d..95e7585 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -14,6 +14,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" +#include "base/process_util.h" #include "base/nix/xdg_util.h" #if defined(OS_FREEBSD) @@ -25,10 +26,6 @@ namespace base { -#if defined(OS_LINUX) -const char kSelfExe[] = "/proc/self/exe"; -#endif - bool PathProviderPosix(int key, FilePath* result) { FilePath path; switch (key) { @@ -36,8 +33,8 @@ bool PathProviderPosix(int key, FilePath* result) { case base::FILE_MODULE: { // TODO(evanm): is this correct? #if defined(OS_LINUX) FilePath bin_dir; - if (!file_util::ReadSymbolicLink(FilePath(kSelfExe), &bin_dir)) { - NOTREACHED() << "Unable to resolve " << kSelfExe << "."; + if (!file_util::ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { + NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; return false; } *result = bin_dir; @@ -65,7 +62,7 @@ bool PathProviderPosix(int key, FilePath* result) { return true; #elif defined(OS_OPENBSD) // There is currently no way to get the executable path on OpenBSD - char *cpath; + char* cpath; if ((cpath = getenv("CHROME_EXE_PATH")) != NULL) *result = FilePath(cpath); else diff --git a/base/process_util.h b/base/process_util.h index dad52cf..cf358dc 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -205,6 +205,9 @@ const int kMaxOomScore = 1000; // translate the given value into [0, 15]. Some aliasing of values // may occur in that case, of course. BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); + +// /proc/self/exe refers to the current executable. +BASE_EXPORT extern const char kProcSelfExe[]; #endif // defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_POSIX) @@ -706,6 +709,8 @@ class BASE_EXPORT ProcessMetrics { #else class PortProvider { public: + virtual ~PortProvider() {} + // Should return the mach task for |process| if possible, or else // |MACH_PORT_NULL|. Only processes that this returns tasks for will have // metrics on OS X (except for the current process, which always gets diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index 393295a..b463f8e 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -288,6 +288,8 @@ namespace base { size_t g_oom_size = 0U; #endif +const char kProcSelfExe[] = "/proc/self/exe"; + ProcessId GetParentProcessId(ProcessHandle process) { ProcessId pid = ReadProcStatsAndGetFieldAsInt(process, VM_PPID); if (pid) diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc index acdbe8c..f348af6 100644 --- a/chrome/test/base/chrome_test_suite.cc +++ b/chrome/test/base/chrome_test_suite.cc @@ -61,14 +61,15 @@ void RemoveSharedMemoryFile(const std::string& filename) { bool IsCrosPythonProcess() { #if defined(OS_CHROMEOS) char buf[80]; - int num_read = readlink("/proc/self/exe", buf, sizeof(buf) - 1); + int num_read = readlink(base::kProcSelfExe, buf, sizeof(buf) - 1); if (num_read == -1) return false; buf[num_read] = 0; const char kPythonPrefix[] = "/python"; return !strncmp(strrchr(buf, '/'), kPythonPrefix, sizeof(kPythonPrefix) - 1); -#endif // defined(OS_CHROMEOS) +#else return false; +#endif // defined(OS_CHROMEOS) } // In many cases it may be not obvious that a test makes a real DNS lookup. diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 5cbad19..ac0b947 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -81,6 +81,8 @@ #if defined(OS_POSIX) && !defined(OS_MACOSX) #include <sys/stat.h> + +#include "base/process_util.h" #include "content/browser/renderer_host/render_sandbox_host_linux.h" #include "content/browser/zygote_host/zygote_host_impl_linux.h" #endif @@ -108,7 +110,7 @@ void SetupSandbox(const CommandLine& parsed_command_line) { // In Chromium branded builds, developers can set an environment variable to // use the development sandbox. See // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment - if (stat("/proc/self/exe", &st) == 0 && st.st_uid == getuid()) + if (stat(base::kProcSelfExe, &st) == 0 && st.st_uid == getuid()) sandbox_binary = getenv("CHROME_DEVEL_SANDBOX"); #if defined(LINUX_SANDBOX_PATH) diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc index 2de8840..701ea63 100644 --- a/content/common/child_process_host_impl.cc +++ b/content/common/child_process_host_impl.cc @@ -98,7 +98,7 @@ FilePath ChildProcessHost::GetChildPath(int flags) { // Valgrind executable, which then crashes. However, it's almost safe to // assume that the updates won't happen while testing with Valgrind tools. if (child_path.empty() && flags & CHILD_ALLOW_SELF && !RunningOnValgrind()) - child_path = FilePath("/proc/self/exe"); + child_path = FilePath(base::kProcSelfExe); #endif // On most platforms, the child executable is the same as the current diff --git a/content/common/set_process_title.cc b/content/common/set_process_title.cc index 58c2e98..02a6be8 100644 --- a/content/common/set_process_title.cc +++ b/content/common/set_process_title.cc @@ -21,6 +21,7 @@ #include "base/file_path.h" #include "base/file_util.h" +#include "base/process_util.h" #include "base/string_util.h" // Linux/glibc doesn't natively have setproctitle(). #include "content/common/set_process_title_linux.h" @@ -46,7 +47,7 @@ void SetProcessTitleFromCommandLine(const char** main_argv) { // use the path it points at for our process title. Note that this is only for // display purposes and has no TOCTTOU security implications. FilePath target; - FilePath self_exe("/proc/self/exe"); + FilePath self_exe(base::kProcSelfExe); if (file_util::ReadSymbolicLink(self_exe, &target)) { have_argv0 = true; title = target.value(); |