@@ -177,12 +177,22 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
177
177
port = ctx -> new .port ;
178
178
}
179
179
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
+ */
181
186
snprintf (cmd , sizeof (cmd ),
182
187
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
183
188
"-o \"-p %d -c autovacuum=off -c autovacuum_freeze_max_age=2000000000\" "
184
189
"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
186
196
exec_prog (ctx , true, "%s" , cmd );
187
197
188
198
/* wait for the server to start properly */
@@ -200,6 +210,7 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
200
210
void
201
211
stop_postmaster (migratorContext * ctx , bool fast , bool quiet )
202
212
{
213
+ char cmd [MAXPGPATH ];
203
214
const char * bindir ;
204
215
const char * datadir ;
205
216
@@ -216,10 +227,16 @@ stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
216
227
else
217
228
return ; /* no cluster running */
218
229
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 ) ,
221
232
SYSTEMQUOTE "\"%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 );
223
240
224
241
ctx -> postmasterPID = 0 ;
225
242
ctx -> running_cluster = NONE ;
0 commit comments