Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/child_process_launcher.cc

Issue 5172009: This adds some plumbing for propagating the reason for a renderer's death (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload after sync for proper diffs Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/child_process_launcher.h" 5 #include "chrome/browser/child_process_launcher.h"
6 6
7 #include <utility> // For std::pair. 7 #include <utility> // For std::pair.
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lock.h" 10 #include "base/lock.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 bool ChildProcessLauncher::IsStarting() { 304 bool ChildProcessLauncher::IsStarting() {
305 return context_->starting_; 305 return context_->starting_;
306 } 306 }
307 307
308 base::ProcessHandle ChildProcessLauncher::GetHandle() { 308 base::ProcessHandle ChildProcessLauncher::GetHandle() {
309 DCHECK(!context_->starting_); 309 DCHECK(!context_->starting_);
310 return context_->process_.handle(); 310 return context_->process_.handle();
311 } 311 }
312 312
313 bool ChildProcessLauncher::DidProcessCrash() { 313 base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus(
314 bool did_crash, child_exited; 314 int* exit_code) {
315 base::TerminationStatus status;
315 base::ProcessHandle handle = context_->process_.handle(); 316 base::ProcessHandle handle = context_->process_.handle();
316 #if defined(OS_LINUX) 317 #if defined(OS_LINUX)
317 if (context_->zygote_) { 318 if (context_->zygote_) {
318 did_crash = Singleton<ZygoteHost>()->DidProcessCrash(handle, &child_exited); 319 status = Singleton<ZygoteHost>()->GetTerminationStatus(handle,
320 exit_code);
319 } else 321 } else
320 #endif 322 #endif
321 { 323 {
322 did_crash = base::DidProcessCrash(&child_exited, handle); 324 status = base::GetTerminationStatus(handle, exit_code);
323 } 325 }
324 326
325 // POSIX: If the process crashed, then the kernel closed the socket for it 327 // POSIX: If the process crashed, then the kernel closed the socket
326 // and so the child has already died by the time we get here. Since 328 // for it and so the child has already died by the time we get
327 // DidProcessCrash called waitpid with WNOHANG, it'll reap the process. 329 // here. Since GetTerminationStatus called waitpid with WNOHANG,
328 // However, if DidProcessCrash didn't reap the child, we'll need to in 330 // it'll reap the process. However, if GetTerminationStatus didn't
331 // reap the child (because it was still running), we'll need to
329 // Terminate via ProcessWatcher. So we can't close the handle here. 332 // Terminate via ProcessWatcher. So we can't close the handle here.
330 if (child_exited) 333 if (status != base::TERMINATION_STATUS_STILL_RUNNING)
331 context_->process_.Close(); 334 context_->process_.Close();
332 335
333 return did_crash; 336 return status;
334 } 337 }
335 338
336 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { 339 void ChildProcessLauncher::SetProcessBackgrounded(bool background) {
337 DCHECK(!context_->starting_); 340 DCHECK(!context_->starting_);
338 context_->process_.SetProcessBackgrounded(background); 341 context_->process_.SetProcessBackgrounded(background);
339 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698