init: skip exit cleanup while the system image is being restored (#65021)
A ^C during early startup, before anything listens for SIGINT, makes
thread 0 exit through the atexit hook. If that happens while the system
image is being restored, `jl_base_module` is already set from the
image's tag list but the relocations have not been applied yet. The hook
then looks up `Base._atexit` in a half-restored module and segfaults.
Return from the atexit hook after resetting the tty until the image is
restored. The exit path then re-raises the signal, so the process ends
with SIGINT as intended.
Just returning early from the atexit hook before the image is restored
also skipped the libuv cleanup, which is what flushes stderr. On
Windows, errors raised before the image is restored, such as an empty or
incompatible CPU target, were then lost.
Skip only the steps that use Julia objects instead: calling
`Base._atexit`, adopting a thread and running finalizers.
Assisted-by: Claude Code (Opus 5.5)