Browse Source

debugger: clean up

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
481329ee7c
  1. 37
      lib/_debugger.js

37
lib/_debugger.js

@ -75,22 +75,24 @@ function tryConnect(cb) {
}
function trySpawn(cb) {
function killChild() {
if (c) {
c.destroy();
}
if (child) {
child.kill();
child = null;
}
}
if (c) {
c.destroy();
c = null;
}
function trySpawn(cb) {
killChild();
child = spawn(process.execPath, args, { customFds: [0, 1, 2] });
console.log("trySpawn");
setTimeout(function () {
console.log("after timeout");
tryConnect(cb);
}, 1000);
}
@ -445,21 +447,18 @@ function startInterface() {
function tryQuit() {
if (quitTried) return;
quitTried = true;
killChild();
term.close();
console.log("\ndebug done\n");
if (c.writable) {
c.reqContinue(function (res) {
process.exit(0);
});
} else {
process.exit(0);
}
process.exit(0);
}
term.on('SIGINT', tryQuit);
term.on('close', tryQuit);
term.on('line', function(cmd) {
// trim whitespace
cmd = cmd.replace(/^\s*/, '').replace(/\s*$/, '');
if (cmd == 'quit' || cmd == 'q' || cmd == 'exit') {
tryQuit();
@ -471,17 +470,13 @@ function startInterface() {
} else {
console.log("restarting...");
trySpawn(function () {
c.reqContinue(function (res) {
// Wait for break point. (disable raw mode?)
});
c.reqContinue();
});
}
});
} else {
trySpawn(function () {
c.reqContinue(function (res) {
// Wait for break point. (disable raw mode?)
});
c.reqContinue();
});
}

Loading…
Cancel
Save