Expand description
Process exit code handling
Stores the integer value returned from main ( -- Int ) so the C-level
main function can read it after the scheduler joins all strands and
return it as the process exit code.
§Lifetime
- The user’s
seq_mainfunction callspatch_seq_set_exit_codewith the top-of-stack Int just before its stack is freed. - The C
mainfunction callspatch_seq_get_exit_codeafterpatch_seq_scheduler_runreturns and uses the value as the process exit code.
§Concurrency
The exit code is a single atomic global. Only the main strand writes to
it, and only after all spawned strands have finished (since
scheduler_run joins all strands). The C main reads it after
scheduler_run returns. There is no race.
Programs declaring main ( -- ) (void main) never call the setter, so
the exit code remains 0 — matching the historical behavior.
Functions§
- patch_
seq_ get_ exit_ code - Get the process exit code.
- patch_
seq_ set_ exit_ code - Set the process exit code.