aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
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() {