Process lifecycle

Generated programs bake config before rad_runtime_start(argc, argv), then install crash diagnostics and arguments before namespace initializers and user code. Native hosts can use the same entry point; existing constructor setup continues to support hosts which do not call it.

When main returns, the runtime drains tracked async work and deferred callbacks, then stops and joins worker pools. Ordinary uncaught exceptions and sys.exit use the same path and preserve their exit status. Reentrant exit from cleanup does not start another drain. Tests still print their summary after deferred work. Untracked server accept loops do not keep process shutdown alive.

runtime:
  shutdownMs: 5000

RADLANG_SHUTDOWN_MS overrides this setting. The integer range is 0 through 2147483647; 5000 milliseconds is the default, and zero skips pending async work. One monotonic deadline covers scheduler drain and pool joins. Each scheduler pass has the same dispatch caps described in async scheduling. A watchdog terminates with the requested status if a callback or foreign call never returns. Deadline termination can leave unfinished work and buffered output; it does not cancel losing race operations or invoke callbacks after process termination. If the watchdog cannot start, the runtime skips scheduler drain rather than execute unbounded user code without the deadline guard.

Fatal CPU signals retain their async-signal-safe report and signal termination. Emergency out-of-memory/fatal-lock paths also retain their immediate exit, since allocating a shutdown guard or taking runtime locks there is unsafe. HTTP SIGTERM remains graceful; the existing SIGINT and per-send SIGPIPE policies are preserved. Signal registration passes through the core lifecycle module; handlers never enter the scheduler or normal shutdown directly.

runtime.handleReport: true or RADLANG_HANDLE_REPORT=1 prints open resource counts by kind and the count with zero explicit references (would-close) during normal shutdown. This report is disabled by default. It describes resources still open at exit; it does not classify them as unreachable and does not change close/drop behavior. Explicit reference counts cover the handle API’s ownership observations, not arbitrary language aliases.