Skip to content

Conversation

juj
Copy link
Collaborator

@juj juj commented Sep 8, 2025

Closes #25217

Update documentation to reflect the current state of affairs for the meaning of -sEXIT_RUNTIME.

If 1, then completing main() will by default call exit(), unless a refcount
keeps the runtime alive. Call emscripten_exit_with_live_runtime() to finish
main() while keeping the runtime alive. Calling exit() will shut down the
runtime, invoking atexit()s, and flushing stdio streams.
Copy link
Collaborator

@sbc100 sbc100 Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think calling exit() won't do this while the refcount is non-zero.

If you want to override the refcount you would need to call emscripten_force_exit().

Also, maybe mention emscripten_runtime_keepalive_push() alongside emscripten_exit_with_live_runtime() which is basically the same thing but without the unwind.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have docs for emscripten_force_exit and emscripten_exit_with_live_runtime so maybe just say something like See docs for ... rather than duplicating?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXIT_RUNTIME=0 semantics
2 participants