Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6259678

Browse files
committed
Fix bugs in exec.c that prevented pg_upgrade working in Windows.
Backpatch to 9.2 - code before that is quite different and should not have these defects.
1 parent f763b77 commit 6259678

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contrib/pg_upgrade/exec.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exec_prog(const char *log_file, const char *opt_log_file,
5252

5353
old_umask = umask(S_IRWXG | S_IRWXO);
5454

55-
written = strlcpy(cmd, SYSTEMQUOTE, strlen(SYSTEMQUOTE));
55+
written = strlcpy(cmd, SYSTEMQUOTE, sizeof(cmd));
5656
va_start(ap, fmt);
5757
written += vsnprintf(cmd + written, MAXCMDLEN - written, fmt, ap);
5858
va_end(ap);
@@ -95,10 +95,16 @@ exec_prog(const char *log_file, const char *opt_log_file,
9595
log_file);
9696
}
9797

98+
#ifndef WIN32
99+
/*
100+
* Can't do this on Windows, postmaster will still hold the log file
101+
* open if the command was "pg_ctl start".
102+
*/
98103
if ((log = fopen_priv(log_file, "a+")) == NULL)
99104
pg_log(PG_FATAL, "cannot write to log file %s\n", log_file);
100105
fprintf(log, "\n\n");
101106
fclose(log);
107+
#endif
102108

103109
return result == 0;
104110
}

0 commit comments

Comments
 (0)