diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-05 21:44:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-05 21:44:13 +0000 |
commit | 962dd31f9cff7017d90da505e077ea84db9c5e48 (patch) | |
tree | 821a70988ea4e963be58314c5b9b7becab7312fe /base/process_util_linux.cc | |
parent | 3115504c55a338fb3de3684a85b2383b4c4dbbc0 (diff) | |
download | chromium_src-962dd31f9cff7017d90da505e077ea84db9c5e48.zip chromium_src-962dd31f9cff7017d90da505e077ea84db9c5e48.tar.gz chromium_src-962dd31f9cff7017d90da505e077ea84db9c5e48.tar.bz2 |
Implement NamedProcessIterator in base/process_util_mac.mm. Patch by Naoki
Takano <takano.naoki@gmail.com>
Review URL: http://codereview.chromium.org/18192
Review URL: http://codereview.chromium.org/21097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9263 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_linux.cc')
-rw-r--r-- | base/process_util_linux.cc | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index 8f83212..2253ff2 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -14,7 +14,6 @@ #include "base/file_util.h" #include "base/logging.h" -#include "base/platform_thread.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/time.h" @@ -202,62 +201,6 @@ bool NamedProcessIterator::IncludeEntry() { return filter_->Includes(entry_.pid, entry_.ppid); } -int GetProcessCount(const std::wstring& executable_name, - const ProcessFilter* filter) { - int count = 0; - - NamedProcessIterator iter(executable_name, filter); - while (iter.NextProcessEntry()) - ++count; - return count; -} - -bool KillProcesses(const std::wstring& executable_name, int exit_code, - const ProcessFilter* filter) { - bool result = true; - const ProcessEntry* entry; - - NamedProcessIterator iter(executable_name, filter); - while ((entry = iter.NextProcessEntry()) != NULL) - result = KillProcess((*entry).pid, exit_code, true) && result; - - return result; -} - -bool WaitForProcessesToExit(const std::wstring& executable_name, - int wait_milliseconds, - const ProcessFilter* filter) { - bool result = false; - - // TODO(port): This is inefficient, but works if there are multiple procs. - // TODO(port): use waitpid to avoid leaving zombies around - - base::Time end_time = base::Time::Now() + - base::TimeDelta::FromMilliseconds(wait_milliseconds); - do { - NamedProcessIterator iter(executable_name, filter); - if (!iter.NextProcessEntry()) { - result = true; - break; - } - PlatformThread::Sleep(100); - } while ((base::Time::Now() - end_time) > base::TimeDelta()); - - return result; -} - -bool CleanupProcesses(const std::wstring& executable_name, - int wait_milliseconds, - int exit_code, - const ProcessFilter* filter) { - bool exited_cleanly = - WaitForProcessesToExit(executable_name, wait_milliseconds, - filter); - if (!exited_cleanly) - KillProcesses(executable_name, exit_code, filter); - return exited_cleanly; -} - // To have /proc/self/io file you must enable CONFIG_TASK_IO_ACCOUNTING // in your kernel configuration. bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) { |