@@ -63,8 +63,11 @@ exec_prog(const char *log_file, const char *opt_log_file,
63
63
if (written >= MAXCMDLEN )
64
64
pg_log (PG_FATAL , "command too long\n" );
65
65
66
- if ((log = fopen_priv (log_file , "a+ " )) == NULL )
66
+ if ((log = fopen_priv (log_file , "a" )) == NULL )
67
67
pg_log (PG_FATAL , "cannot write to log file %s\n" , log_file );
68
+ #ifdef WIN32
69
+ fprintf (log , "\n\n" );
70
+ #endif
68
71
pg_log (PG_VERBOSE , "%s\n" , cmd );
69
72
fprintf (log , "command: %s\n" , cmd );
70
73
@@ -97,10 +100,13 @@ exec_prog(const char *log_file, const char *opt_log_file,
97
100
98
101
#ifndef WIN32
99
102
/*
100
- * Can't do this on Windows, postmaster will still hold the log file
101
- * open if the command was "pg_ctl start".
103
+ * We can't do this on Windows because it will keep the "pg_ctl start"
104
+ * output filename open until the server stops, so we do the \n\n above
105
+ * on that platform. We use a unique filename for "pg_ctl start" that is
106
+ * never reused while the server is running, so it works fine. We could
107
+ * log these commands to a third file, but that just adds complexity.
102
108
*/
103
- if ((log = fopen_priv (log_file , "a+ " )) == NULL )
109
+ if ((log = fopen_priv (log_file , "a" )) == NULL )
104
110
pg_log (PG_FATAL , "cannot write to log file %s\n" , log_file );
105
111
fprintf (log , "\n\n" );
106
112
fclose (log );
0 commit comments