aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-10 18:22:14 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-10 18:22:14 -0800
commit99634e23408315efe0633cd1917794081f4ec4ba (patch)
treeb3539c98addcfff2fcf5b7f2c1d75c71fe9e887f /src
parent6e77a01fabb47edf569c517b3566d8ba6dd43480 (diff)
NO_EXIT_RUNTIME option, to set Module.noExitRuntime during compilation
Diffstat (limited to 'src')
-rw-r--r--src/postamble.js4
-rw-r--r--src/preamble.js5
-rw-r--r--src/settings.js2
3 files changed, 11 insertions, 0 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 90a86474..382d3117 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -202,6 +202,10 @@ if (Module['noInitialRun']) {
shouldRunNow = false;
}
+#if NO_EXIT_RUNTIME
+Module["noExitRuntime"] = true;
+#endif
+
run();
// {{POST_RUN_ADDITIONS}}
diff --git a/src/preamble.js b/src/preamble.js
index 25ef1fb3..5038e9c4 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -1027,6 +1027,11 @@ function preMain() {
}
function exitRuntime() {
+#if ASSERTIONS
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module.printErr('Exiting runtime. Any attempt to access the compiled C code may fail from now. If you want to keep the runtime alive, set Module["noExitRuntime"] = true or build with -s NO_EXIT_RUNTIME=1');
+ }
+#endif
callRuntimeCallbacks(__ATEXIT__);
}
diff --git a/src/settings.js b/src/settings.js
index 79e949fa..1db91dca 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -48,6 +48,8 @@ var VERBOSE = 0; // When set to 1, will generate more verbose output during comp
var INVOKE_RUN = 1; // Whether we will run the main() function. Disable if you embed the generated
// code in your own, and will call main() yourself at the right time (which you
// can do with Module.callMain(), with an optional parameter of commandline args).
+var NO_EXIT_RUNTIME = 0; // If set, the runtime is not quit when main() completes (allowing code to
+ // run afterwards, for example from the browser main event loop).
var INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to 0.
var TOTAL_STACK = 5*1024*1024; // The total stack size. There is no way to enlarge the stack, so this
// value must be large enough for the program's requirements. If