Last active
December 16, 2015 16:49
-
-
Save mainiak/5466515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
node exit.js | |
echo "return code: $?" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"mscdex: also the removeListener usage is unnecessary since node only executes the 'exit' handler once (it has a guard in place)" from #node.js