Fix crash caused by BrowserWindow.destroy().

This commit is contained in:
Cheng Zhao 2013-12-27 15:41:00 +08:00
parent 6312c1108a
commit f28881e203

View file

@ -4,6 +4,7 @@
#include "browser/api/atom_api_window.h" #include "browser/api/atom_api_window.h"
#include "base/bind.h"
#include "base/process/kill.h" #include "base/process/kill.h"
#include "browser/native_window.h" #include "browser/native_window.h"
#include "common/v8/native_type_conversions.h" #include "common/v8/native_type_conversions.h"
@ -127,11 +128,12 @@ void Window::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
base::ProcessHandle handle = self->window_->GetRenderProcessHandle(); base::ProcessHandle handle = self->window_->GetRenderProcessHandle();
delete self; delete self;
// Check if the render process is terminated, it could happen that the render // Make sure the renderer process is terminated, it could happen that the
// became a zombie. // renderer process became a zombie.
if (!base::WaitForSingleProcess(handle, base::MessageLoop::current()->PostDelayedTask(
base::TimeDelta::FromMilliseconds(500))) FROM_HERE,
base::KillProcess(handle, 0, true); base::Bind(base::IgnoreResult(base::KillProcess), 0, false, handle),
base::TimeDelta::FromMilliseconds(5000));
} }
// static // static