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\r\n"); 14 15 ret = atexit(my_exit1); 16 if(ret != 0) 17 err_sys("can‘t not register my_exit1\r\n"); 18 19 ret = atexit(my_exit1); 20 if(ret != 0) 21 err_sys("can‘t not register my_exit1\r\n"); 22 23 printf("main done\r\n"); 24 25 exit(0); 26 27 } 28 29 static void my_exit1(void) 30 { 31 printf("first exit handler\r\n"); 32 } 33 static void my_exit2(void) 34 { 35 printf("second exit handler\r\n"); 36 }
时间: 2024-10-09 20:26:24