diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 18:50:48 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 18:50:48 +0000 |
commit | f3c1d3c50ad3ab6afd7b36283baf8b03b7228456 (patch) | |
tree | d39ac5f46f1fff0974d216a5607af69990df962b /content | |
parent | a05c4e1277023acdfab0aa821ed06eca012f08d3 (diff) | |
download | chromium_src-f3c1d3c50ad3ab6afd7b36283baf8b03b7228456.zip chromium_src-f3c1d3c50ad3ab6afd7b36283baf8b03b7228456.tar.gz chromium_src-f3c1d3c50ad3ab6afd7b36283baf8b03b7228456.tar.bz2 |
Fix bug that caused Task Manager to display defunct GPU processes after they were killed. This change makes it OK to call GetChildTerminationStatus after the process handle has been nulled out. Previously, the process kill notification was never getting sent out because of the check for a null handle.
Also verified that the related bug fix (http://code.google.com/p/chromium/issues/detail?id=88769) is still fixed.
BUG=89488
TEST=open CSS Poster Circle page; open Task Manager; kill GPU process; verify there are not two GPU processes in the Task Manager.
Review URL: http://codereview.chromium.org/7466013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/browser_child_process_host.cc | 5 | ||||
-rw-r--r-- | content/browser/child_process_launcher.cc | 24 |
2 files changed, 20 insertions, 9 deletions
diff --git a/content/browser/browser_child_process_host.cc b/content/browser/browser_child_process_host.cc index addca3d..40b6598 100644 --- a/content/browser/browser_child_process_host.cc +++ b/content/browser/browser_child_process_host.cc @@ -125,10 +125,7 @@ base::TerminationStatus BrowserChildProcessHost::GetChildTerminationStatus( void BrowserChildProcessHost::OnChildDied() { // This may be called by both the channel's OnChannelError handler - // as well as the process launcher's OnProcessLaunched handler, so - // we need to be careful about the state of the process launcher here. - if (child_process_.get() && !child_process_->IsStarting()) - set_handle(child_process_->GetHandle()); + // as well as the process launcher's OnProcessLaunched handler. if (handle() != base::kNullProcessHandle) { int exit_code; base::TerminationStatus status = GetChildTerminationStatus(&exit_code); diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 79d5429..3c4180e 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -43,6 +43,8 @@ class ChildProcessLauncher::Context Context() : client_(NULL), client_thread_id_(BrowserThread::UI), + termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION), + exit_code_(content::RESULT_CODE_NORMAL_EXIT), starting_(true), terminate_child_on_shutdown_(true) #if defined(OS_POSIX) && !defined(OS_MACOSX) @@ -293,6 +295,8 @@ class ChildProcessLauncher::Context Client* client_; BrowserThread::ID client_thread_id_; base::Process process_; + base::TerminationStatus termination_status_; + int exit_code_; bool starting_; // Controls whether the child process should be terminated on browser // shutdown. Default behavior is to terminate the child. @@ -342,27 +346,37 @@ base::ProcessHandle ChildProcessLauncher::GetHandle() { base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus( int* exit_code) { - base::TerminationStatus status; base::ProcessHandle handle = context_->process_.handle(); + if (handle == base::kNullProcessHandle) { + // Process is already gone, so return the cached termination status. + if (exit_code) + *exit_code = context_->exit_code_; + return context_->termination_status_; + } #if defined(OS_POSIX) && !defined(OS_MACOSX) if (context_->zygote_) { - status = ZygoteHost::GetInstance()->GetTerminationStatus(handle, exit_code); + context_->termination_status_ = ZygoteHost::GetInstance()-> + GetTerminationStatus(handle, &context_->exit_code_); } else #endif { - status = base::GetTerminationStatus(handle, exit_code); + context_->termination_status_ = + base::GetTerminationStatus(handle, &context_->exit_code_); } + if (exit_code) + *exit_code = context_->exit_code_; + // POSIX: If the process crashed, then the kernel closed the socket // for it and so the child has already died by the time we get // here. Since GetTerminationStatus called waitpid with WNOHANG, // it'll reap the process. However, if GetTerminationStatus didn't // reap the child (because it was still running), we'll need to // Terminate via ProcessWatcher. So we can't close the handle here. - if (status != base::TERMINATION_STATUS_STILL_RUNNING) + if (context_->termination_status_ != base::TERMINATION_STATUS_STILL_RUNNING) context_->process_.Close(); - return status; + return context_->termination_status_; } void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |