diff options
-rw-r--r-- | src/library.js | 7 | ||||
-rw-r--r-- | src/postamble.js | 18 | ||||
-rw-r--r-- | src/settings.js | 6 | ||||
-rwxr-xr-x | tests/runner.py | 6 |
4 files changed, 10 insertions, 27 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 diff --git a/tests/runner.py b/tests/runner.py index 168567d2..db33c817 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2716,7 +2716,6 @@ Exiting setjmp function, level: 0, prev_jmp: -1 if Settings.ASM_JS: return self.skip('uses report_stack without exporting') Settings.INLINING_LIMIT = 50 - Settings.CATCH_EXIT_CODE = 1 src = r''' #include <stdio.h> @@ -2757,7 +2756,7 @@ Exiting setjmp function, level: 0, prev_jmp: -1 ''') self.emcc_args += ['--pre-js', 'pre.js'] - self.do_run(src, '''reported\npostRun\nok.\nExit Status: 1\n''') + self.do_run(src, '''reported\nExit Status: 1\npostRun\nok.\n''') def test_class(self): src = ''' @@ -8673,8 +8672,6 @@ def process(filename): Settings.CORRECT_SIGNS = 0 def test_exit_status(self): - Settings.CATCH_EXIT_CODE = 1 - src = r''' #include <stdio.h> #include <stdlib.h> @@ -8869,7 +8866,6 @@ class %s(T): Settings.INCLUDE_FULL_LIBRARY = 0 Settings.BUILD_AS_SHARED_LIB = 0 Settings.RUNTIME_LINKED_LIBS = [] - Settings.CATCH_EXIT_CODE = 0 Settings.EMULATE_UNALIGNED_ACCESSES = int(Settings.USE_TYPED_ARRAYS == 2 and Building.LLVM_OPTS == 2) Settings.DOUBLE_MODE = 1 if Settings.USE_TYPED_ARRAYS and Building.LLVM_OPTS == 0 else 0 Settings.PRECISE_I64_MATH = 0 |