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 MylesBorins committed Jan 31, 2017
1 parent 3ac9e01 commit 90bd36b
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 @@ -515,10 +515,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 90bd36b

Please sign in to comment.