diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-12-30 21:18:25 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-12-30 21:18:25 +0300 |
commit | 481329ee7c4ca7f5fdb57ad6f687f229baec461e (patch) | |
tree | 2a6f5e974633a24cb5129c2aefd90d0c87b5d954 /lib | |
parent | f484cbf4c7bbbc8549de55984c072cf2f1132c7a (diff) |
debugger: clean up
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_debugger.js | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/_debugger.js b/lib/_debugger.js index a3649105978..c84d2b823e4 100644 --- a/lib/_debugger.js +++ b/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(); }); } |