diff --git a/lib/repl.js b/lib/repl.js index 7140e1b56c3dfa..a7eb22e396e847 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -87,10 +87,13 @@ const { propertyFilter: { ALL_PROPERTIES, SKIP_SYMBOLS - }, + } +} = internalBinding('util'); +const { startSigintWatchdog, stopSigintWatchdog -} = internalBinding('util'); +} = internalBinding('contextify'); + const history = require('internal/repl/history'); // Lazy-loaded. diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 25b8b28ecd54b6..f8d43e062eef24 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1141,6 +1141,20 @@ void ContextifyContext::CompileFunction( args.GetReturnValue().Set(fn); } +static void StartSigintWatchdog(const FunctionCallbackInfo& args) { + int ret = SigintWatchdogHelper::GetInstance()->Start(); + args.GetReturnValue().Set(ret == 0); +} + +static void StopSigintWatchdog(const FunctionCallbackInfo& args) { + bool had_pending_signals = SigintWatchdogHelper::GetInstance()->Stop(); + args.GetReturnValue().Set(had_pending_signals); +} + +static void WatchdogHasPendingSigint(const FunctionCallbackInfo& args) { + bool ret = SigintWatchdogHelper::GetInstance()->HasPendingSignal(); + args.GetReturnValue().Set(ret); +} void Initialize(Local target, Local unused, @@ -1149,6 +1163,12 @@ void Initialize(Local target, Environment* env = Environment::GetCurrent(context); ContextifyContext::Init(env, target); ContextifyScript::Init(env, target); + + env->SetMethod(target, "startSigintWatchdog", StartSigintWatchdog); + env->SetMethod(target, "stopSigintWatchdog", StopSigintWatchdog); + // Used in tests. + env->SetMethodNoSideEffect( + target, "watchdogHasPendingSigint", WatchdogHasPendingSigint); } } // namespace contextify diff --git a/src/node_util.cc b/src/node_util.cc index d13624a436a9b9..961df0b73c3deb 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -1,5 +1,4 @@ #include "node_errors.h" -#include "node_watchdog.h" #include "util.h" #include "base_object-inl.h" @@ -157,24 +156,6 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(maybe_value.FromJust()); } - -void StartSigintWatchdog(const FunctionCallbackInfo& args) { - int ret = SigintWatchdogHelper::GetInstance()->Start(); - args.GetReturnValue().Set(ret == 0); -} - - -void StopSigintWatchdog(const FunctionCallbackInfo& args) { - bool had_pending_signals = SigintWatchdogHelper::GetInstance()->Stop(); - args.GetReturnValue().Set(had_pending_signals); -} - - -void WatchdogHasPendingSigint(const FunctionCallbackInfo& args) { - bool ret = SigintWatchdogHelper::GetInstance()->HasPendingSignal(); - args.GetReturnValue().Set(ret); -} - void ArrayBufferViewHasBuffer(const FunctionCallbackInfo& args) { CHECK(args[0]->IsArrayBufferView()); args.GetReturnValue().Set(args[0].As()->HasBuffer()); @@ -281,11 +262,6 @@ void Initialize(Local target, env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties", GetOwnNonIndexProperties); - env->SetMethod(target, "startSigintWatchdog", StartSigintWatchdog); - env->SetMethod(target, "stopSigintWatchdog", StopSigintWatchdog); - env->SetMethodNoSideEffect(target, "watchdogHasPendingSigint", - WatchdogHasPendingSigint); - env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); Local constants = Object::New(env->isolate()); NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES); diff --git a/test/parallel/test-util-sigint-watchdog.js b/test/parallel/test-util-sigint-watchdog.js index 7ac1261eabab40..67a8f61539c673 100644 --- a/test/parallel/test-util-sigint-watchdog.js +++ b/test/parallel/test-util-sigint-watchdog.js @@ -8,7 +8,7 @@ if (common.isWindows) { const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); -const binding = internalBinding('util'); +const binding = internalBinding('contextify'); [(next) => { // Test with no signal observed.