diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-30 16:57:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-30 16:57:20 -0700 |
commit | 6fd2313192352995c36d1097e18f591dc65d81d1 (patch) | |
tree | fb8856e31b14159ecfcd6227fe2d518977cca5e5 /src/postamble.js | |
parent | cde63dfcbbf0981a09ad0cf8fa28bf7cbe0b6340 (diff) |
show exit status if exit() is called within main(); fixes test_exit_status
Diffstat (limited to 'src/postamble.js')
-rw-r--r-- | src/postamble.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/postamble.js b/src/postamble.js index 2a6885d4..54aea3ef 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -39,10 +39,11 @@ Module['callMain'] = function callMain(args) { ret = Module['_main'](argc, argv, 0); } catch(e) { - if (e == 'Exited') { + if (e && typeof e == 'object' && e.type == 'ExitStatus') { // exit() throws this once it's done to make sure execution // has been stopped completely - return; + Module.print('Exit Status: ' + e.value); + return e.value; } else if (e == 'SimulateInfiniteLoop') { // running an evented main loop, don't immediately exit Module['noExitRuntime'] = true; @@ -132,7 +133,7 @@ function exit(status) { if (inMain) { // if we're still inside the callMain's try/catch, we need to throw an // exception in order to immediately terminate execution. - throw 'Exited'; + throw { type: 'ExitStatus', value: status }; } } Module['exit'] = Module.exit = exit; |