|
|
@ -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(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|