Make sure browserWindow.destroy() doesn't leave zombie processes.
This commit is contained in:
parent
687c9de5d7
commit
e45f83e62a
3 changed files with 16 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "browser/api/atom_api_window.h"
|
||||
|
||||
#include "base/process_util.h"
|
||||
#include "base/values.h"
|
||||
#include "browser/native_window.h"
|
||||
#include "common/v8_conversions.h"
|
||||
|
@ -126,8 +127,15 @@ v8::Handle<v8::Value> Window::New(const v8::Arguments &args) {
|
|||
v8::Handle<v8::Value> Window::Destroy(const v8::Arguments &args) {
|
||||
UNWRAP_WINDOW_AND_CHECK;
|
||||
|
||||
base::ProcessHandle handle = self->window_->GetRenderProcessHandle();
|
||||
delete self;
|
||||
|
||||
// Check if the render process is terminated, it could happen that the render
|
||||
// became a zombie.
|
||||
if (!base::WaitForSingleProcess(handle,
|
||||
base::TimeDelta::FromMilliseconds(500)))
|
||||
base::KillProcess(handle, 0, true);
|
||||
|
||||
return v8::Undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,10 @@ bool NativeWindow::SetIcon(const std::string& str_path) {
|
|||
return true;
|
||||
}
|
||||
|
||||
base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
|
||||
return GetWebContents()->GetRenderProcessHost()->GetHandle();
|
||||
}
|
||||
|
||||
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||
const CapturePageCallback& callback) {
|
||||
GetWebContents()->GetRenderViewHost()->CopyFromBackingStore(
|
||||
|
|
|
@ -114,6 +114,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual void RestartHangMonitorTimeout();
|
||||
virtual bool SetIcon(const std::string& path);
|
||||
|
||||
// Returns the process handle of render process, useful for killing the
|
||||
// render process manually
|
||||
virtual base::ProcessHandle GetRenderProcessHandle();
|
||||
|
||||
// Captures the page with |rect|, |callback| would be called when capturing is
|
||||
// done.
|
||||
virtual void CapturePage(const gfx::Rect& rect,
|
||||
|
|
Loading…
Add table
Reference in a new issue