1 #include "apue.h" 2 3 static void my_exit1(void); 4 static void my_exit2(void); 5 6 7 int main(void) 8 { 9 int ret = -1; 10 11 ret = atexit(my_exit2); 12 if(ret != 0) 13 err_sys("can't not register my_exit2 "); 14 15 ret = atexit(my_exit1); 16 if(ret != 0) 17 err_sys("can't not register my_exit1 "); 18 19 ret = atexit(my_exit1); 20 if(ret != 0) 21 err_sys("can't not register my_exit1 "); 22 23 printf("main done "); 24 25 exit(0); 26 27 } 28 29 static void my_exit1(void) 30 { 31 printf("first exit handler "); 32 } 33 static void my_exit2(void) 34 { 35 printf("second exit handler "); 36 }