Skip to content

Commit 4162abb

Browse files
Eugene OstroukhovMylesBorins
authored andcommitted
inspector: check if connected before waiting
Fixes: #10093 PR-URL: #10094 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 3666879 commit 4162abb

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎src/inspector_agent.cc‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,12 @@ bool AgentImpl::IsStarted() {
515515
}
516516

517517
voidAgentImpl::WaitForDisconnect() {
518-
shutting_down_ = true;
519-
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
520-
fflush(stderr);
521-
inspector_->runMessageLoopOnPause(0);
518+
if (state_ == State::kConnected) {
519+
shutting_down_ = true;
520+
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
521+
fflush(stderr);
522+
inspector_->runMessageLoopOnPause(0);
523+
}
522524
}
523525

524526
#defineREADONLY_PROPERTY(obj, str, var) \
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
require('../common');
3+
constspawn=require('child_process').spawn;
4+
5+
constchild=spawn(process.execPath,
6+
['--inspect','no-such-script.js'],
7+
{'stdio': 'inherit'});
8+
9+
functionsignalHandler(value){
10+
child.kill();
11+
process.exit(1);
12+
}
13+
14+
process.on('SIGINT',signalHandler);
15+
process.on('SIGTERM',signalHandler);

0 commit comments

Comments
 (0)