The function: int atexit (void (*function) (void))
allows us to call the same exit handling functions more than once. Why would you call the exit handlers more than once?
Could you give me an example where it makes sense to call the same exit handler more than once.
Asked
Active
Viewed 153 times
-1
1 Answers
1
I would reverse the diagnostic: the function atexit
has no simple way to know if a handling function has already been registered, so it does not even try to identify that.
For that reason it does not forbid it.
But I agree with you I cannot find a real user case for registering the same handler more than once.

Serge Ballesta
- 143,923
- 11
- 122
- 252
-
If you have a singleton hell... for example a Logger, and some other singleton that uses a Logger you may end up reinitializing the logger and calling atexit again... although this is a sign that you are doing something wrong i think, but if you have a third party singleton and you use it in your own singletons nobody knows what'll happen – Martin Kosicky Dec 27 '17 at 12:03