diff --git a/CHANGES.md b/CHANGES.md index 263afd1..1025c03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## 4.5.3 (not yet released) -(nothing yet) +- #52 Fix 'triton ssh ...' stdout/stderr to fully flush with node >= 4.x. ## 4.5.2 diff --git a/lib/do_instance/do_ssh.js b/lib/do_instance/do_ssh.js index 5330963..8546c48 100644 --- a/lib/do_instance/do_ssh.js +++ b/lib/do_instance/do_ssh.js @@ -50,8 +50,19 @@ function do_ssh(subcmd, opts, args, callback) { args = ['-l', user].concat(ip).concat(args); self.top.log.info({args: args}, 'forking ssh'); - var child = spawn('ssh', args, {stdio: 'inherit'}); + var child = spawn('ssh', args); + child.stdout.on('data', function (chunk){ + process.stdout.write(chunk); + }); + child.stderr.on('data', function (chunk){ + process.stderr.write(chunk); + }); child.on('close', function (code) { + /* + * Once node 0.10 support is dropped we could instead: + * process.exitCode = code; + * callback(); + */ process.exit(code); }); });