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

Commit5fe8c7d

Browse files
committed
More restructuring to use Win32 START with paths needing quotes.
1 parent6cc4175 commit5fe8c7d

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 51 additions & 4 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.13 2004/06/10 22:20:53 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.14 2004/06/11 00:57:25 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -221,6 +221,41 @@ start_postmaster(void)
221221
* to pass everything to a shell to process them.
222222
*/
223223
charcmd[MAXPGPATH];
224+
intret;
225+
char*pgexec=postgres_path;
226+
227+
#ifdefWIN32
228+
/*
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.
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
224259

225260
if (log_file!=NULL)
226261
/* Win32 needs START /B rather than "&" */
@@ -229,16 +264,28 @@ start_postmaster(void)
229264
#else
230265
snprintf(cmd,MAXPGPATH,"%sSTART /B \"%s\" %s < \"%s\" >> \"%s\" 2>&1%s",
231266
#endif
232-
SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,log_file,
267+
SYSTEMQUOTE,pgexec,post_opts,DEVNULL,log_file,
233268
SYSTEMQUOTE);
234269
else
235270
#ifndefWIN32
236271
snprintf(cmd,MAXPGPATH,"%s\"%s\" %s < \"%s\" 2>&1 &%s",
237272
#else
238273
snprintf(cmd,MAXPGPATH,"%sSTART /B \"%s\" %s < \"%s\" 2>&1%s",
239274
#endif
240-
SYSTEMQUOTE,postgres_path,post_opts,DEVNULL,SYSTEMQUOTE);
241-
returnsystem(cmd);
275+
SYSTEMQUOTE,pgexec,post_opts,DEVNULL,SYSTEMQUOTE);
276+
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;
242289
}
243290

244291

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp