diff --git a/base/process/process_iterator_linux.cc b/base/process/process_iterator_linux.cc index 94a35766e969d..421565f8e412e 100644 --- a/base/process/process_iterator_linux.cc +++ b/base/process/process_iterator_linux.cc @@ -61,18 +61,28 @@ bool GetProcCmdline(pid_t pid, std::vector* proc_cmd_line_args) { ProcessIterator::ProcessIterator(const ProcessFilter* filter) : filter_(filter) { procfs_dir_ = opendir(internal::kProcDir); + if (!procfs_dir_) { + // On Android, SELinux may prevent reading /proc. See + // https://crbug.com/581517 for details. + PLOG(ERROR) << "opendir " << internal::kProcDir; + } } ProcessIterator::~ProcessIterator() { if (procfs_dir_) { closedir(procfs_dir_); - procfs_dir_ = NULL; + procfs_dir_ = nullptr; } } bool ProcessIterator::CheckForNextProcess() { // TODO(port): skip processes owned by different UID + if (!procfs_dir_) { + DLOG(ERROR) << "Skipping CheckForNextProcess(), no procfs_dir_"; + return false; + } + pid_t pid = kNullProcessId; std::vector cmd_line_args; std::string stats_data;