OLD | NEW |
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 bool ChildProcessLauncher::IsStarting() { | 302 bool ChildProcessLauncher::IsStarting() { |
303 return context_->starting_; | 303 return context_->starting_; |
304 } | 304 } |
305 | 305 |
306 base::ProcessHandle ChildProcessLauncher::GetHandle() { | 306 base::ProcessHandle ChildProcessLauncher::GetHandle() { |
307 DCHECK(!context_->starting_); | 307 DCHECK(!context_->starting_); |
308 return context_->process_.handle(); | 308 return context_->process_.handle(); |
309 } | 309 } |
310 | 310 |
311 bool ChildProcessLauncher::DidProcessCrash() { | 311 base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus( |
312 bool did_crash, child_exited; | 312 int* exit_code) { |
| 313 base::TerminationStatus status; |
313 base::ProcessHandle handle = context_->process_.handle(); | 314 base::ProcessHandle handle = context_->process_.handle(); |
314 #if defined(OS_LINUX) | 315 #if defined(OS_LINUX) |
315 if (context_->zygote_) { | 316 if (context_->zygote_) { |
316 did_crash = Singleton<ZygoteHost>()->DidProcessCrash(handle, &child_exited); | 317 status = Singleton<ZygoteHost>()->GetTerminationStatus(handle, |
| 318 exit_code); |
317 } else | 319 } else |
318 #endif | 320 #endif |
319 { | 321 { |
320 did_crash = base::DidProcessCrash(&child_exited, handle); | 322 status = base::GetTerminationStatus(handle, exit_code); |
321 } | 323 } |
322 | 324 |
323 // POSIX: If the process crashed, then the kernel closed the socket for it | 325 // POSIX: If the process crashed, then the kernel closed the socket |
324 // and so the child has already died by the time we get here. Since | 326 // for it and so the child has already died by the time we get |
325 // DidProcessCrash called waitpid with WNOHANG, it'll reap the process. | 327 // here. Since GetTerminationStatus called waitpid with WNOHANG, |
326 // However, if DidProcessCrash didn't reap the child, we'll need to in | 328 // it'll reap the process. However, if GetTerminationStatus didn't |
| 329 // reap the child (because it was still running), we'll need to |
327 // Terminate via ProcessWatcher. So we can't close the handle here. | 330 // Terminate via ProcessWatcher. So we can't close the handle here. |
328 if (child_exited) | 331 if (status != base::TERMINATION_STATUS_STILL_RUNNING) |
329 context_->process_.Close(); | 332 context_->process_.Close(); |
330 | 333 |
331 return did_crash; | 334 return status; |
332 } | 335 } |
333 | 336 |
334 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 337 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
335 DCHECK(!context_->starting_); | 338 DCHECK(!context_->starting_); |
336 context_->process_.SetProcessBackgrounded(background); | 339 context_->process_.SetProcessBackgrounded(background); |
337 } | 340 } |
OLD | NEW |