From 8e05fe33503f4e334a3a057790c94e098158bc9b Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 17 Jun 2015 20:13:43 +0530 Subject: [PATCH] process: add hang method --- atom/common/api/atom_bindings.cc | 6 ++++++ docs/api/process.md | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index a210cc6931d..fa4a88d5843 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -26,6 +26,11 @@ void Crash() { static_cast(NULL)->crash = true; } +void Hang() { + for (;;) + base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); +} + // Called when there is a fatal error in V8, we just crash the process here so // we can get the stack trace. void FatalErrorCallback(const char* location, const char* message) { @@ -54,6 +59,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate, mate::Dictionary dict(isolate, process); dict.SetMethod("crash", &Crash); + dict.SetMethod("hang", &Hang); dict.SetMethod("log", &Log); dict.SetMethod("activateUvLoop", base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this))); diff --git a/docs/api/process.md b/docs/api/process.md index 4afa6677b8a..c9efa22fe0f 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -7,3 +7,7 @@ upstream node: * `process.versions['electron']` String - Version of Electron. * `process.versions['chrome']` String - Version of Chromium. * `process.resourcesPath` String - Path to JavaScript source code. + +## process.hang + +Causes the main thread of the current process hang.