Ensure only non-truncating values are returned from `main()`.

POSIX allows any `int` value to be returned but specifies that only
the low 8 bits are available in some contexts:
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/_exit.html

For reasons that aren't entirely clear, WASI requires the value to be
in range [0;126), and this is enforced with an assertion at runtime
level in Wasmtime. This should probably be fixed in Wasmtime but until
it is done there doesn't seem to be any harm in returning `125` instead
of `-1`. This also removes any discrepancy due to truncation.
This commit is contained in:
Catherine 2026-05-01 11:22:38 +00:00
parent 6cf255cc2b
commit 1407b33558
1 changed files with 2 additions and 2 deletions

View File

@ -748,7 +748,7 @@ int CommandHandler::exec()
{
try {
if (!parseOptions())
return -1;
return 125;
if (executeBeforeContext())
return 0;
@ -764,7 +764,7 @@ int CommandHandler::exec()
return rc;
} catch (log_execution_error_exception) {
printFooter();
return -1;
return 125;
}
}