diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-02 21:06:59 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-07 01:26:04 +0300 |
commit | 7e2a182d03c40faa567daebee5ce064675190bff (patch) | |
tree | 6f592972d6e0d188de01b04a9bb2b726cf7dae72 /src/inspector_agent.cc | |
parent | 5bf43729a403b992cc90b5cdbbaaf505769d1107 (diff) |
src: make WaitForInspectorDisconnect an exit hook
Run inspector cleanup code on Environment teardown.
This is part of a series of changes to make embedding easier, by
requiring fewer internal methods to build a fully functioning
Node.js instance.
PR-URL: https://github.com/nodejs/node/pull/30229
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Diffstat (limited to 'src/inspector_agent.cc')
-rw-r--r-- | src/inspector_agent.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 469e0b4f8f3..f13e68c0675 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -778,6 +778,13 @@ bool Agent::Start(const std::string& path, StartDebugSignalHandler(); } + AtExit(parent_env_, [](void* env) { + Agent* agent = static_cast<Environment*>(env)->inspector_agent(); + if (agent->IsActive()) { + agent->WaitForDisconnect(); + } + }, parent_env_); + bool wait_for_connect = options.wait_for_connect(); if (parent_handle_) { wait_for_connect = parent_handle_->WaitForConnect(); |