diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 01:48:04 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 01:48:04 +0000 |
commit | 71867010345983eaedb185c90d9a81641d61e233 (patch) | |
tree | 76ecd09841cee818bb097fd77a8d023aaff9bc75 /base | |
parent | e2827d03c170101a3bb827739da06aae02f0b291 (diff) | |
download | chromium_src-71867010345983eaedb185c90d9a81641d61e233.zip chromium_src-71867010345983eaedb185c90d9a81641d61e233.tar.gz chromium_src-71867010345983eaedb185c90d9a81641d61e233.tar.bz2 |
Linux: Return a failure in ReadProcStats() if the stat file is empty.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10579050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_linux.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index ddad967..124b8ec 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -48,7 +48,8 @@ enum ProcStatsFields { VM_RSS = 23, // Resident Set Size in pages. }; -// Reads /proc/<pid>/stat into |buffer|. Returns true if successful. +// Reads /proc/<pid>/stat into |buffer|. Returns true if the file can be read +// and is non-empty. bool ReadProcStats(pid_t pid, std::string* buffer) { buffer->clear(); // Synchronously reading files in /proc is safe. @@ -59,7 +60,7 @@ bool ReadProcStats(pid_t pid, std::string* buffer) { DLOG(WARNING) << "Failed to get process stats."; return false; } - return true; + return !buffer->empty(); } // Takes |stats_data| and populates |proc_stats| with the values split by |