Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ jobs:
wasmfs.test_fs_llseek_rawfs
wasmfs.test_freetype
minimal0.test_utf
minimal0.test_static_variable
omitexports0.test_asyncify_longjmp
strict.test_no_declare_asm_module_exports
"
Expand Down
18 changes: 17 additions & 1 deletion src/postamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,23 @@ function run() {
_main({{{ argc_argv() }}}).then(exitRuntime);
#elif EXIT_RUNTIME
// In regular exitRuntime mode, exit with the given return code from main().
exitRuntime(_main({{{ argc_argv() }}}));
try {
exitRuntime(_main({{{ argc_argv() }}}));
} catch(e) {
var exitCode = e.match(/^exit\(\d+\)$/);
if (exitCode) {
throw e;
}
#if RUNTIME_DEBUG
dbg(`main() called ${e}.`); // e.g. "main() called exit(0)."
#endif
// Report to Module that the program exited. TODO: Find a way to not emit
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wrap this in #if expectToReceiveOnModule('onExit').

// this code unconditionally, as it may not be needed by the user. In
// MINIMAL_RUNTIME, the use of Module object is discouraged, since it leads
// to non-DCEable patterns of code. This call is present here mainly for
// Emscripten test harness purposes.
Module['onExit']?.(exitCode[1]);
}
#else
// Run a persistent (never-exiting) application starting at main().
_main({{{ argc_argv() }}});
Expand Down
Loading