diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 23:27:11 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-24 23:27:11 +0000 |
commit | 6466e2cedc3398c6bbf8227c5a2c8c1cb9253a75 (patch) | |
tree | 68fa3542f422b3298286829a69cf337a1e434d21 /chrome/common/process_watcher_win.cc | |
parent | 1ef1023581b9f58105864d771cc4cdbe45a29532 (diff) | |
download | chromium_src-6466e2cedc3398c6bbf8227c5a2c8c1cb9253a75.zip chromium_src-6466e2cedc3398c6bbf8227c5a2c8c1cb9253a75.tar.gz chromium_src-6466e2cedc3398c6bbf8227c5a2c8c1cb9253a75.tar.bz2 |
Revert "POSIX: Don't spawn zombies." (r14488)
Something else is trying to reap children in the ui_tests and causing
a mess. Reverting since it's a Friday night.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/process_watcher_win.cc')
-rw-r--r-- | chrome/common/process_watcher_win.cc | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/chrome/common/process_watcher_win.cc b/chrome/common/process_watcher_win.cc deleted file mode 100644 index 1ee7edf..0000000 --- a/chrome/common/process_watcher_win.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/process_watcher.h" - -#include "base/message_loop.h" -#include "base/object_watcher.h" -#include "base/sys_info.h" -#include "chrome/common/env_vars.h" -#include "chrome/common/result_codes.h" - -// Maximum amount of time (in milliseconds) to wait for the process to exit. -static const int kWaitInterval = 2000; - -namespace { - -class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate { - public: - explicit TimerExpiredTask(base::ProcessHandle process) : process_(process) { - watcher_.StartWatching(process_, this); - } - - virtual ~TimerExpiredTask() { - if (process_) { - KillProcess(); - DCHECK(!process_) << "Make sure to close the handle."; - } - } - - // Task --------------------------------------------------------------------- - - virtual void Run() { - if (process_) - KillProcess(); - } - - // MessageLoop::Watcher ----------------------------------------------------- - - virtual void OnObjectSignaled(HANDLE object) { - // When we're called from KillProcess, the ObjectWatcher may still be - // watching. the process handle, so make sure it has stopped. - watcher_.StopWatching(); - - CloseHandle(process_); - process_ = NULL; - } - - private: - void KillProcess() { - if (base::SysInfo::HasEnvVar(env_vars::kHeadless)) { - // If running the distributed tests, give the renderer a little time - // to figure out that the channel is shutdown and unwind. - if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) { - OnObjectSignaled(process_); - return; - } - } - - // OK, time to get frisky. We don't actually care when the process - // terminates. We just care that it eventually terminates, and that's what - // TerminateProcess should do for us. Don't check for the result code since - // it fails quite often. This should be investigated eventually. - TerminateProcess(process_, ResultCodes::HUNG); - - // Now, just cleanup as if the process exited normally. - OnObjectSignaled(process_); - } - - // The process that we are watching. - base::ProcessHandle process_; - - base::ObjectWatcher watcher_; - - DISALLOW_EVIL_CONSTRUCTORS(TimerExpiredTask); -}; - -} // namespace - -// static -void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) { - DCHECK(process != GetCurrentProcess()); - - // If already signaled, then we are done! - if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { - CloseHandle(process); - return; - } - - MessageLoop::current()->PostDelayedTask(FROM_HERE, - new TimerExpiredTask(process), - kWaitInterval); -} |