It is unspecified whether a call to the
atexit
function that does not happen before theexit
function is called will succeed.
ISO C standard, §7.22.4.2. So both behaviors are compliant; you can't reliably register a function using atexit
while exit
is already running its atexit
handlers.