Skip to content

Instantly share code, notes, and snippets.

@markdaws
markdaws / flushStdOutAndErrOnExit
Created August 11, 2011 22:11
Shutting down node.js and flushing stdout and stderr
function flushAndShutdown(exitCode) {
if(process.stdout.flush()) {
process.exit(exitCode);
}
else {
process.stdout.on('drain', function() {
process.exit(exitCode);
})
}
}