Skip to content

Commit b41db33

Browse files
Eugene OstroukhovFishrock123
authored andcommitted
inspector: check if connected before waiting
Fixes: #10093 PR-URL: #10094 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 19d7197 commit b41db33

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎src/inspector_agent.cc‎

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

550550
voidAgentImpl::WaitForDisconnect(){
551-
shutting_down_ = true;
552-
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
553-
fflush(stderr);
554-
inspector_->runMessageLoopOnPause(0);
551+
if (state_ == State::kConnected){
552+
shutting_down_ = true;
553+
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
554+
fflush(stderr);
555+
inspector_->runMessageLoopOnPause(0);
556+
}
555557
}
556558

557559
#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)