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

Commitf885449

Browse files
committed
On Windows, use COMSPEC to find the location of cmd.exe.
Historically, psql consulted COMSPEC to spawn a shell in its \! command,but we just invoked "cmd" when spawning shells in pg_ctl and pg_regress.It seems better to rely on the environment variable, if it's set,in all cases.It's debatable whether this is a bug fix or just a behavioral change,so no back-patch.Juan José Santamaría FlechaDiscussion:https://postgr.es/m/16080-5d7f03222469f717@postgresql.org
1 parentbd1ef57 commitf885449

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,19 @@ start_postmaster(void)
513513
* "exec", so we don't get to find out the postmaster's PID immediately.
514514
*/
515515
PROCESS_INFORMATIONpi;
516+
constchar*comspec;
517+
518+
/* Find CMD.EXE location using COMSPEC, if it's set */
519+
comspec=getenv("COMSPEC");
520+
if (comspec==NULL)
521+
comspec="CMD";
516522

517523
if (log_file!=NULL)
518-
snprintf(cmd,MAXPGPATH,"CMD /C \"\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1\"",
519-
exec_path,pgdata_opt,post_opts,DEVNULL,log_file);
524+
snprintf(cmd,MAXPGPATH,"\"%s\" /C \"\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1\"",
525+
comspec,exec_path,pgdata_opt,post_opts,DEVNULL,log_file);
520526
else
521-
snprintf(cmd,MAXPGPATH,"CMD /C \"\"%s\" %s%s < \"%s\" 2>&1\"",
522-
exec_path,pgdata_opt,post_opts,DEVNULL);
527+
snprintf(cmd,MAXPGPATH,"\"%s\" /C \"\"%s\" %s%s < \"%s\" 2>&1\"",
528+
comspec,exec_path,pgdata_opt,post_opts,DEVNULL);
523529

524530
if (!CreateRestrictedProcess(cmd,&pi, false))
525531
{

‎src/test/regress/pg_regress.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,15 @@ spawn_process(const char *cmdline)
11931193
PROCESS_INFORMATIONpi;
11941194
char*cmdline2;
11951195
HANDLErestrictedToken;
1196+
constchar*comspec;
1197+
1198+
/* Find CMD.EXE location using COMSPEC, if it's set */
1199+
comspec=getenv("COMSPEC");
1200+
if (comspec==NULL)
1201+
comspec="CMD";
11961202

11971203
memset(&pi,0,sizeof(pi));
1198-
cmdline2=psprintf("cmd /c \"%s\"",cmdline);
1204+
cmdline2=psprintf("\"%s\" /c \"%s\"",comspec,cmdline);
11991205

12001206
if ((restrictedToken=
12011207
CreateRestrictedProcess(cmdline2,&pi))==0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp