|
4 | 4 | * |
5 | 5 | * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group |
6 | 6 | * |
7 | | - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.15 2004/06/1104:17:21 momjian Exp $ |
| 7 | + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.16 2004/06/1116:36:31 momjian Exp $ |
8 | 8 | * |
9 | 9 | *------------------------------------------------------------------------- |
10 | 10 | */ |
@@ -221,71 +221,33 @@ start_postmaster(void) |
221 | 221 | * to pass everything to a shell to process them. |
222 | 222 | */ |
223 | 223 | charcmd[MAXPGPATH]; |
224 | | -intret; |
225 | | -char*pgexec=postgres_path; |
226 | 224 |
|
227 | | -#ifdefWIN32 |
228 | 225 | /* |
229 | | - *Win32 has a problem with the interaction between START and system(). |
230 | | - *There is no way to quote the executable name passed to START. |
231 | | - *Therefore, we put the executable name in a temporary batch file |
232 | | - *and run it via START. |
| 226 | + * Win32 needs START /B rather than "&". |
| 227 | + * |
| 228 | + *Win32 has a problem with START and quoted executable names. |
| 229 | + *You must add a "" as the title at the beginning so you can quote |
| 230 | + *the executable name: |
| 231 | + *http://www.winnetmag.com/Article/ArticleID/14589/14589.html |
| 232 | + *http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm |
233 | 233 | */ |
234 | | -chartmp[MAXPGPATH]="C:\\PG_CTL_XXXXXX",/* good location? */ |
235 | | -bat[MAXPGPATH]; |
236 | | -intfd=mkstemp(tmp); |
237 | | - |
238 | | -if (fd==-1) |
239 | | -{ |
240 | | -fprintf(stderr,_("%s: cannot create batch file %s to start server: %s\n"), |
241 | | -progname,tmp,strerror(errno)); |
242 | | -exit(1); |
243 | | -} |
244 | | -write(fd,postgres_path,strlen(postgres_path)); |
245 | | -write(fd,"\n",1); |
246 | | -close(fd); |
247 | | - |
248 | | -strcpy(bat,tmp); |
249 | | -strcat(bat,".BAT"); |
250 | | -pgexec=bat; |
251 | | -if (rename(tmp,bat)==-1) |
252 | | -{ |
253 | | -fprintf(stderr,_("%s: cannot rename batch file %s to %s: %s\n"), |
254 | | -progname,tmp,bat,strerror(errno)); |
255 | | -unlink(tmp); |
256 | | -exit(1); |
257 | | -} |
258 | | -#endif |
259 | | - |
260 | 234 | if (log_file!=NULL) |
261 | | -/* Win32 needs START /B rather than "&" */ |
262 | 235 | #ifndefWIN32 |
263 | 236 | snprintf(cmd,MAXPGPATH,"%s\"%s\" %s < \"%s\" >> \"%s\" 2>&1 &%s", |
264 | 237 | #else |
265 | | -snprintf(cmd,MAXPGPATH,"%sSTART /B%s %s < \"%s\" >> \"%s\" 2>&1%s", |
| 238 | +snprintf(cmd,MAXPGPATH,"%sSTART /B\"\" \"%s\" %s < \"%s\" >> \"%s\" 2>&1%s", |
266 | 239 | #endif |
267 | | -SYSTEMQUOTE,pgexec,post_opts,DEVNULL,log_file, |
| 240 | +SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,log_file, |
268 | 241 | SYSTEMQUOTE); |
269 | 242 | else |
270 | 243 | #ifndefWIN32 |
271 | 244 | snprintf(cmd,MAXPGPATH,"%s\"%s\" %s < \"%s\" 2>&1 &%s", |
272 | 245 | #else |
273 | | -snprintf(cmd,MAXPGPATH,"%sSTART /B%s %s < \"%s\" 2>&1%s", |
| 246 | +snprintf(cmd,MAXPGPATH,"%sSTART /B\"\" \"%s\" %s < \"%s\" 2>&1%s", |
274 | 247 | #endif |
275 | | -SYSTEMQUOTE,pgexec,post_opts,DEVNULL,SYSTEMQUOTE); |
| 248 | +SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,SYSTEMQUOTE); |
276 | 249 |
|
277 | | -ret=system(cmd); |
278 | | - |
279 | | -#ifdefWIN32 |
280 | | -/* We are unlinking it while it is running, but that should be OK */ |
281 | | -if (unlink(bat)) |
282 | | -{ |
283 | | -fprintf(stderr,_("%s: cannot remove batch file %s: %s\n"), |
284 | | -progname,bat,strerror(errno)); |
285 | | -exit(1); |
286 | | -} |
287 | | -#endif |
288 | | -returnret; |
| 250 | +returnsystem(cmd); |
289 | 251 | } |
290 | 252 |
|
291 | 253 |
|
|