Skip to content

Instantly share code, notes, and snippets.

@mainiak
Last active December 16, 2015 16:49
Show Gist options
  • Select an option

  • Save mainiak/5466515 to your computer and use it in GitHub Desktop.

Select an option

Save mainiak/5466515 to your computer and use it in GitHub Desktop.
var exitCode = 0;
process.on("exit", onExit);
function onExit() {
//process.removeListener("exit", onExit); // redundant
process.exit(exitCode);
}
exitCode = 3;
process.exit(); // value is dropped anyway
#!/bin/sh
node exit.js
echo "return code: $?"
@mainiak

mainiak commented Apr 26, 2013

Copy link
Copy Markdown
Author

"mscdex: also the removeListener usage is unnecessary since node only executes the 'exit' handler once (it has a guard in place)" from #node.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment