Skip to content

Commit

Permalink
inspector: check if connected before waiting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eugene Ostroukhov authored and Fishrock123 committed Dec 13, 2016
1 parent 19d7197 commit b41db33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,12 @@ bool AgentImpl::IsStarted() {
}

void AgentImpl::WaitForDisconnect() {
shutting_down_ = true;
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
fflush(stderr);
inspector_->runMessageLoopOnPause(0);
if (state_ == State::kConnected) {
shutting_down_ = true;
fprintf(stderr, "Waiting for the debugger to disconnect...\n");
fflush(stderr);
inspector_->runMessageLoopOnPause(0);
}
}

#define READONLY_PROPERTY(obj, str, var) \
Expand Down
15 changes: 15 additions & 0 deletions test/inspector/test-inspector-stops-no-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
require('../common');
const spawn = require('child_process').spawn;

const child = spawn(process.execPath,
[ '--inspect', 'no-such-script.js' ],
{ 'stdio': 'inherit' });

function signalHandler(value) {
child.kill();
process.exit(1);
}

process.on('SIGINT', signalHandler);
process.on('SIGTERM', signalHandler);

0 comments on commit b41db33

Please sign in to comment.