1 #include <config.h> 2 3 #include "log.h" 4 5 extern const char *progname; /* for msyslog use too */ 6 7 static int counter = 0; 8 9 static void cleanup_log(void); 10 11 void 12 sntp_init_logging( 13 const char *prog 14 ) 15 { 16 17 msyslog_term = TRUE; 18 init_logging(prog, 0, FALSE); 19 msyslog_term_pid = FALSE; 20 msyslog_include_timestamp = FALSE; 21 } 22 23 24 void 25 open_logfile( 26 const char *logfile 27 ) 28 { 29 change_logfile(logfile, FALSE); 30 counter = 1; //counter++; 31 atexit(cleanup_log); 32 } 33 34 //not sure about this. Are the atexit() functions called by FIFO or LIFO order? The end result is PROBABLY the same 35 static void 36 cleanup_log(void) 37 { 38 //counter--; 39 //if(counter <= 0){ 40 if(counter == 1){ 41 syslogit = TRUE; 42 fflush(syslog_file); 43 fclose(syslog_file); 44 syslog_file = NULL; 45 counter = 0; 46 } 47 } 48