@@ -177,12 +177,22 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
177177port = ctx -> new .port ;
178178}
179179
180- /* use -l for Win32 */
180+ /*
181+ * On Win32, we can't send both server output and pg_ctl output
182+ * to the same file because we get the error:
183+ * "The process cannot access the file because it is being used by another process."
184+ * so we have to send pg_ctl output to 'nul'.
185+ */
181186snprintf (cmd ,sizeof (cmd ),
182187SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
183188"-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
184189"start >> \"%s\" 2>&1" SYSTEMQUOTE ,
185- bindir ,ctx -> logfile ,datadir ,port ,ctx -> logfile );
190+ bindir ,ctx -> logfile ,datadir ,port ,
191+ #ifndef WIN32
192+ ctx -> logfile );
193+ #else
194+ DEVNULL );
195+ #endif
186196exec_prog (ctx , true,"%s" ,cmd );
187197
188198/* wait for the server to start properly */
@@ -200,6 +210,7 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
200210void
201211stop_postmaster (migratorContext * ctx ,bool fast ,bool quiet )
202212{
213+ char cmd [MAXPGPATH ];
203214const char * bindir ;
204215const char * datadir ;
205216
@@ -216,10 +227,16 @@ stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
216227else
217228return ;/* no cluster running */
218229
219- /*use -l for Win32 */
220- exec_prog ( ctx , fast ? false : true ,
230+ /*See comment in start_postmaster() about why win32 output is ignored. */
231+ snprintf ( cmd , sizeof ( cmd ) ,
221232SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> \"%s\" 2>&1" SYSTEMQUOTE ,
222- bindir ,ctx -> logfile ,datadir ,fast ?"-m fast" :"" ,ctx -> logfile );
233+ bindir ,ctx -> logfile ,datadir ,fast ?"-m fast" :"" ,
234+ #ifndef WIN32
235+ ctx -> logfile );
236+ #else
237+ DEVNULL );
238+ #endif
239+ exec_prog (ctx ,fast ? false : true,"%s" ,cmd );
223240
224241ctx -> postmasterPID = 0 ;
225242ctx -> running_cluster = NONE ;