When is the C language standard library function atexit called?

The

code is as follows:
void F1 (void) {

printf("Running f1.\n");

}

void f2 (void) {

printf("Running f2.\n");

}

int main () {

printf("Registering f1 and f2: ");

if(atexit(f1)||atexit(f2)){
    printf("failed.\n");
}
else{
    printf("done.\n");
    exit(0);
}

}
the running result is as follows:
Registering F1 and f2: done.
Running f2.
Running f1.
my question is:
when the program runs to if, how do I know the return value of the atexit function? I see that the instructions on the atexit function are all called when the program exits normally, but now that the program has not exited at the time of if judgment, how does the program judge?

C
Mar.03,2021

atexit simply registers a function that returns whether the registration was successful or not. The registered function will not run until the main function exits.

Menu