aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2012-09-03 15:31:26 -0400
committerAndrew Dunstan <andrew@dunslane.net>2012-09-03 15:31:26 -0400
commit6259678f8f5443e9d396e20418448b247c6948dd (patch)
tree61299b2abb19c06f5bf7674b33eb5731b98e351c
parentf763b77193b04eba03a1f4ce46df34dc0348419e (diff)
downloadpostgresql-6259678f8f5443e9d396e20418448b247c6948dd.tar.gz
postgresql-6259678f8f5443e9d396e20418448b247c6948dd.zip
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.
-rw-r--r--contrib/pg_upgrade/exec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c
index c75d9dbcc97..ac46a9b9369 100644
--- a/contrib/pg_upgrade/exec.c
+++ b/contrib/pg_upgrade/exec.c
@@ -52,7 +52,7 @@ exec_prog(const char *log_file, const char *opt_log_file,
old_umask = umask(S_IRWXG | S_IRWXO);
- written = strlcpy(cmd, SYSTEMQUOTE, strlen(SYSTEMQUOTE));
+ written = strlcpy(cmd, SYSTEMQUOTE, sizeof(cmd));
va_start(ap, fmt);
written += vsnprintf(cmd + written, MAXCMDLEN - written, fmt, ap);
va_end(ap);
@@ -95,10 +95,16 @@ exec_prog(const char *log_file, const char *opt_log_file,
log_file);
}
+#ifndef WIN32
+ /*
+ * Can't do this on Windows, postmaster will still hold the log file
+ * open if the command was "pg_ctl start".
+ */
if ((log = fopen_priv(log_file, "a+")) == NULL)
pg_log(PG_FATAL, "cannot write to log file %s\n", log_file);
fprintf(log, "\n\n");
fclose(log);
+#endif
return result == 0;
}