aboutsummaryrefslogtreecommitdiff
path: root/src/postamble.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/postamble.js
parentb9522ed475bda6fda0cad4a7302d9f23b4529ad0 (diff)
parentca12d620e84fc5284976fb3ecfb8ef30ee7cfe4a (diff)
Merge pull request #116 from eclecticdave/master
exit() throws uncaught exception
Diffstat (limited to 'src/postamble.js')
-rw-r--r--src/postamble.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/postamble.js b/src/postamble.js
index c8fd44bd..51ffc6ee 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -17,7 +17,14 @@ Module.callMain = function callMain(args) {
argv.push(0);
argv = allocate(argv, 'i32', ALLOC_STATIC);
+#if CATCH_EXIT_CODE
+ try {
+ return _main(argc, argv, 0);
+ }
+ catch(e) { if (e.name == "ExitStatus") return e.status; throw e; }
+#else
return _main(argc, argv, 0);
+#endif
}
{{GLOBAL_VARS}}
@@ -49,7 +56,10 @@ Module['noInitialRun'] = true;
#endif
if (!Module['noInitialRun']) {
- run();
+ var ret = run();
+#if CATCH_EXIT_CODE
+ print('Exit Status: ' + ret);
+#endif
}
// {{POST_RUN_ADDITIONS}}