aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-02 20:10:19 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-02 20:10:19 -0800
commit0bea4bec8e1e21c280f99264cc7ec68ed4820717 (patch)
treeb42bcf4ed61564f6e491686893d2beb3a9f56419 /src/library.js
parentb9522ed475bda6fda0cad4a7302d9f23b4529ad0 (diff)
parentca12d620e84fc5284976fb3ecfb8ef30ee7cfe4a (diff)
Merge pull request #116 from eclecticdave/master
exit() throws uncaught exception
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js
index 113c955c..1f63e6d0 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1752,9 +1752,25 @@ LibraryManager.library = {
_exit: function(status) {
// void _exit(int status);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
+
+#if CATCH_EXIT_CODE
+ function ExitStatus() {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+ };
+ ExitStatus.prototype = new Error();
+ ExitStatus.prototype.constructor = ExitStatus;
+#endif
+
__shutdownRuntime__();
ABORT = true;
+
+#if CATCH_EXIT_CODE
+ throw new ExitStatus();
+#else
throw 'exit(' + status + ') called, at ' + new Error().stack;
+#endif
},
fork__deps: ['__setErrNo', '$ERRNO_CODES'],
fork: function() {