Is it guaranteed that a function registered with atexit will ALWAYS be called upon normal program termination? (I encounterd a scenario in FreeBSD where a function that I register with atexit never gets called, even when the program terminates normally).
No. First, the function will not be called if atexit
returns a non-0 value. Secondly, it won't be called if a function registered before it doesn't return normally.