Search code examples
catexit

Can we deregister an exit handler that has been registered with atexit()


is it possible to unregister an exit handler function???

void exit_handler_1()
{
    printf("in first exit handler\n");
}

int main()
{
    if(atexit(exit_handler_1())
    {
        perror("error");
    }
    return 0;
}

Solution

  • It is not possible.

    Why not just register one atexit function and have a global variable for that function to be able to decide what is required of it.