| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 base::ProcessHandle ChildProcessLauncher::GetHandle() { | 205 base::ProcessHandle ChildProcessLauncher::GetHandle() { |
| 206 DCHECK(!context_->starting_); | 206 DCHECK(!context_->starting_); |
| 207 return context_->process_.handle(); | 207 return context_->process_.handle(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool ChildProcessLauncher::DidProcessCrash() { | 210 bool ChildProcessLauncher::DidProcessCrash() { |
| 211 bool did_crash, child_exited; | 211 bool did_crash, child_exited; |
| 212 base::ProcessHandle handle = context_->process_.handle(); | 212 base::ProcessHandle handle = context_->process_.handle(); |
| 213 #if defined(OS_LINUX) |
| 213 if (context_->zygote_) { | 214 if (context_->zygote_) { |
| 214 #if defined(OS_LINUX) | |
| 215 did_crash = Singleton<ZygoteHost>()->DidProcessCrash(handle, &child_exited); | 215 did_crash = Singleton<ZygoteHost>()->DidProcessCrash(handle, &child_exited); |
| 216 } else |
| 216 #endif | 217 #endif |
| 217 } else { | 218 { |
| 218 did_crash = base::DidProcessCrash(&child_exited, handle); | 219 did_crash = base::DidProcessCrash(&child_exited, handle); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // POSIX: If the process crashed, then the kernel closed the socket for it | 222 // POSIX: If the process crashed, then the kernel closed the socket for it |
| 222 // and so the child has already died by the time we get here. Since | 223 // and so the child has already died by the time we get here. Since |
| 223 // DidProcessCrash called waitpid with WNOHANG, it'll reap the process. | 224 // DidProcessCrash called waitpid with WNOHANG, it'll reap the process. |
| 224 // However, if DidProcessCrash didn't reap the child, we'll need to in | 225 // However, if DidProcessCrash didn't reap the child, we'll need to in |
| 225 // Terminate via ProcessWatcher. So we can't close the handle here. | 226 // Terminate via ProcessWatcher. So we can't close the handle here. |
| 226 // | 227 // |
| 227 // This is moot on Windows where |child_exited| will always be true. | 228 // This is moot on Windows where |child_exited| will always be true. |
| 228 if (child_exited) | 229 if (child_exited) |
| 229 context_->process_.Close(); | 230 context_->process_.Close(); |
| 230 | 231 |
| 231 return did_crash; | 232 return did_crash; |
| 232 } | 233 } |
| 233 | 234 |
| 234 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 235 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
| 235 DCHECK(!context_->starting_); | 236 DCHECK(!context_->starting_); |
| 236 context_->process_.SetProcessBackgrounded(background); | 237 context_->process_.SetProcessBackgrounded(background); |
| 237 } | 238 } |
| OLD | NEW |