Search code examples
c++cfreebsdatexit

Function registered with atexit() not getting called


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).


Solution

  • 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.