@@ -733,15 +733,19 @@ _dispatch_logv_init(void *context DISPATCH_UNUSED)
733
733
dispatch_log_basetime = _dispatch_absolute_time ();
734
734
#endif
735
735
#if defined(_WIN32 )
736
- FILE * pLogFile = _fdopen (dispatch_logfile , "w" );
737
-
738
736
char szProgramName [MAX_PATH + 1 ] = {0 };
739
737
GetModuleFileNameA (NULL , szProgramName , MAX_PATH );
740
738
741
- fprintf (pLogFile , "=== log file opened for %s[%lu] at "
742
- "%ld.%06u ===\n" , szProgramName , GetCurrentProcessId (),
743
- tv .tv_sec , (int )tv .tv_usec );
744
- fclose (pLogFile );
739
+ char szMessage [512 ];
740
+ int len = snprintf (szMessage , sizeof (szMessage ),
741
+ "=== log file opened for %s[%lu] at %ld.%06u ===" ,
742
+ szProgramName , GetCurrentProcessId (), tv .tv_sec ,
743
+ (int )tv .tv_usec );
744
+ if (len > 0 ) {
745
+ len = MIN (len , sizeof (szMessage ) - 1 );
746
+ _write (dispatch_logfile , szMessage , len );
747
+ _write (dispatch_logfile , "\n" , 1 );
748
+ }
745
749
#else
746
750
dprintf (dispatch_logfile , "=== log file opened for %s[%u] at "
747
751
"%ld.%06u ===\n" , getprogname () ?: "" , getpid (),
0 commit comments