From feb11debf62bbb01a5599e6c6be1e7c5607fd2db Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Thu, 8 Dec 2011 22:59:29 -0800 Subject: [PATCH] Close stdin in all the places we could have opened it. OH GOD IT BURNS MY EYES!!!! Asana ticket filed. --- app/skybreak/skybreak.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/skybreak/skybreak.js b/app/skybreak/skybreak.js index 8d3d97174f..dd3355fd21 100644 --- a/app/skybreak/skybreak.js +++ b/app/skybreak/skybreak.js @@ -365,9 +365,12 @@ var run_mongo_shell = function (url) { if (auth) args.push('-p', auth[1]); args.push(mongo_url.hostname + ':' + mongo_url.port + mongo_url.pathname); - spawn(mongo_path, - args, - { customFds: [0, 1, 2] }); + var proc = spawn(mongo_path, + args, + { customFds: [0, 1, 2] }); + proc.on('exit', function () { + process.stdin.destroy(); // clean up after maybe_password + }); }; Commands.push({ @@ -459,10 +462,19 @@ Commands.push({ res.on('data', function (chunk) { data += chunk; }); res.on('end', function () { if (res.statusCode == 200) { - if (new_argv.url) + if (new_argv.url) { console.log(data); - else + + // only do this if we're printing the URL. Don't do it + // if we're running the mongo shell, since that will + // close off stdin for the shell. + process.stdin.destroy(); // clean up after maybe_password + } else { + // pause stdin so we don't try to read it while mongo is + // running. + process.stdin.pause(); run_mongo_shell(data); + } } else { process.stderr.write(data); @@ -597,6 +609,9 @@ Commands.push({ tar.on('exit', function (code) { deploy_req.end(); }); + + // XXX this is gross. maybe some way to automate? + process.stdin.destroy(); // clean up after maybe_password }; deploy.maybe_password(url.hostname, function (password) { @@ -648,6 +663,9 @@ Commands.push({ console.log("Error connecting to Skybreak: " + e.message); process.exit(1); }); + + // XXX this is gross. maybe some way to automate? + process.stdin.destroy(); // clean up after maybe_password }); } });