Search code examples
cexitatexit

Why would you call the same Exit Handlers (atexit function) more than once?


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.


Solution

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