Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d64b56

Browse files
committed
Cleanup use of Win32 START by using "" for title. No need for temp
batch files anymore.
1 parent800910f commit8d64b56

File tree

1 file changed

+13
-51
lines changed

1 file changed

+13
-51
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
*
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 $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -221,71 +221,33 @@ start_postmaster(void)
221221
* to pass everything to a shell to process them.
222222
*/
223223
charcmd[MAXPGPATH];
224-
intret;
225-
char*pgexec=postgres_path;
226224

227-
#ifdefWIN32
228225
/*
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
233233
*/
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-
260234
if (log_file!=NULL)
261-
/* Win32 needs START /B rather than "&" */
262235
#ifndefWIN32
263236
snprintf(cmd,MAXPGPATH,"%s\"%s\" %s < \"%s\" >> \"%s\" 2>&1 &%s",
264237
#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",
266239
#endif
267-
SYSTEMQUOTE,pgexec,post_opts,DEVNULL,log_file,
240+
SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,log_file,
268241
SYSTEMQUOTE);
269242
else
270243
#ifndefWIN32
271244
snprintf(cmd,MAXPGPATH,"%s\"%s\" %s < \"%s\" 2>&1 &%s",
272245
#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",
274247
#endif
275-
SYSTEMQUOTE,pgexec,post_opts,DEVNULL,SYSTEMQUOTE);
248+
SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,SYSTEMQUOTE);
276249

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);
289251
}
290252

291253

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp