aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-20 15:45:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-03-20 15:45:48 -0700
commit187d2517eebb3d92921f9183609f0aa681492f37 (patch)
tree9d8542e4f3c06697e12f2934f2cb4e81abeadb7a /src
parent6159c4f1565a180999563dc70092f2db2e0b6562 (diff)
remove CATCH_EXIT_CODE and make it the default behavior
Diffstat (limited to 'src')
-rw-r--r--src/library.js7
-rw-r--r--src/postamble.js18
-rw-r--r--src/settings.js6
3 files changed, 9 insertions, 22 deletions
diff --git a/src/library.js b/src/library.js
index aebad63b..3ee6f505 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2061,24 +2061,19 @@ LibraryManager.library = {
// 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;
+ Module.print('Exit Status: ' + status);
};
ExitStatus.prototype = new Error();
ExitStatus.prototype.constructor = ExitStatus;
-#endif
exitRuntime();
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() {
diff --git a/src/postamble.js b/src/postamble.js
index 00205abc..9ee93673 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -23,18 +23,19 @@ Module.callMain = function callMain(args) {
var ret;
-#if CATCH_EXIT_CODE
var initialStackTop = STACKTOP;
try {
ret = Module['_main'](argc, argv, 0);
}
- catch(e) { if (e.name == "ExitStatus") return e.status; throw e; }
- finally {
+ catch(e) {
+ if (e.name == 'ExitStatus') {
+ return e.status;
+ } else {
+ throw e;
+ }
+ } finally {
STACKTOP = initialStackTop;
}
-#else
- ret = Module['_main'](argc, argv, 0);
-#endif
#if BENCHMARK
Module.realPrint('main() took ' + (Date.now() - start) + ' milliseconds');
@@ -121,10 +122,7 @@ if (Module['noInitialRun']) {
}
if (shouldRunNow) {
- var ret = run();
-#if CATCH_EXIT_CODE
- Module.print('Exit Status: ' + ret);
-#endif
+ run();
}
// {{POST_RUN_ADDITIONS}}
diff --git a/src/settings.js b/src/settings.js
index 97963ac5..9ed87bd6 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -113,12 +113,6 @@ var INLINING_LIMIT = 0; // A limit on inlining. If 0, we will inline normally i
// we will prevent inlining of functions of this size or larger
// in closure. 50 is a reasonable setting if you do not want
// inlining
-var CATCH_EXIT_CODE = 0; // If set, causes exit() to throw an exception object which is caught
- // in a try..catch block and results in the exit status being
- // returned from run(). If zero (the default), the program is just
- // terminated with an error message, that is, the exception thrown
- // by exit() is not handled in any way (in particular, the stack
- // position will not be reset).
// Generated code debugging options
var SAFE_HEAP = 0; // Check each write to the heap, for example, this will give a clear