Skip to content

Commit 91e88b8

Browse files
authored
Update documentation on -sEXIT_RUNTIME. (#25218)
Closes #25217 Update documentation to reflect the current state of affairs for the meaning of `-sEXIT_RUNTIME`.
1 parent 406505c commit 91e88b8

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,25 @@ Default value: true
8585
EXIT_RUNTIME
8686
============
8787

88-
If 0, the runtime is not quit when main() completes (allowing code to
89-
run afterwards, for example from the browser main event loop). atexit()s
90-
are also not executed, and we can avoid including code for runtime shutdown,
91-
like flushing the stdio streams.
92-
Set this to 1 if you do want atexit()s or stdio streams to be flushed
93-
on exit.
88+
If 0, support for shutting down the runtime is not emitted into the build.
89+
This means that the program is not quit when main() completes, but execution
90+
will yield to the event loop of the JS environment, allowing event handlers
91+
to run afterwards. If 0, C++ global destructors will not be emitted into the
92+
build either, to save on code size. Calling exit() will throw an unwinding
93+
exception, but will not shut down the runtime.
94+
95+
Set this to 1 if you do want to retain the ability to shut down the program.
96+
If 1, then completing main() will by default call exit(), unless a refcount
97+
keeps the runtime alive. Call emscripten_exit_with_live_runtime() to finish
98+
main() while keeping the runtime alive. Calling emscripten_force_exit() will
99+
shut down the runtime, invoking atexit()s, and flushing stdio streams.
94100
This setting is controlled automatically in STANDALONE_WASM mode:
95101

96102
- For a command (has a main function) this is always 1
97-
- For a reactor (no a main function) this is always 0
103+
- For a reactor (no main function) this is always 0
104+
105+
For more details, see documentation for emscripten_force_exit() and
106+
emscripten_exit_with_live_runtime().
98107

99108
Default value: false
100109

src/settings.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,25 @@ var VERBOSE = false;
8383
// [link]
8484
var INVOKE_RUN = true;
8585

86-
// If 0, the runtime is not quit when main() completes (allowing code to
87-
// run afterwards, for example from the browser main event loop). atexit()s
88-
// are also not executed, and we can avoid including code for runtime shutdown,
89-
// like flushing the stdio streams.
90-
// Set this to 1 if you do want atexit()s or stdio streams to be flushed
91-
// on exit.
86+
// If 0, support for shutting down the runtime is not emitted into the build.
87+
// This means that the program is not quit when main() completes, but execution
88+
// will yield to the event loop of the JS environment, allowing event handlers
89+
// to run afterwards. If 0, C++ global destructors will not be emitted into the
90+
// build either, to save on code size. Calling exit() will throw an unwinding
91+
// exception, but will not shut down the runtime.
92+
//
93+
// Set this to 1 if you do want to retain the ability to shut down the program.
94+
// If 1, then completing main() will by default call exit(), unless a refcount
95+
// keeps the runtime alive. Call emscripten_exit_with_live_runtime() to finish
96+
// main() while keeping the runtime alive. Calling emscripten_force_exit() will
97+
// shut down the runtime, invoking atexit()s, and flushing stdio streams.
9298
// This setting is controlled automatically in STANDALONE_WASM mode:
9399
//
94100
// - For a command (has a main function) this is always 1
95-
// - For a reactor (no a main function) this is always 0
101+
// - For a reactor (no main function) this is always 0
96102
//
103+
// For more details, see documentation for emscripten_force_exit() and
104+
// emscripten_exit_with_live_runtime().
97105
// [link]
98106
var EXIT_RUNTIME = false;
99107

0 commit comments

Comments
 (0)