pg_ctl-16259.patch
text/x-patch
Filename: pg_ctl-16259.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/pg_ctl/pg_ctl.c | 9 | 6 |
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index bcb1ddb1351..29ac12173a8 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -529,15 +529,18 @@ start_postmaster(void)
* previous postmaster will still have the file open for a short time
* after removing postmaster.pid.)
*/
- FILE *fd = fopen(log_file, "a");
+ int fd = open(log_file, O_RDWR, 0);
- if (fd == NULL)
+ if (fd == -1)
{
- write_stderr(_("%s: could not create log file \"%s\": %s\n"),
- progname, log_file, strerror(errno));
- exit(1);
+ if (errno != ENOENT) {
+ write_stderr(_("%s: could not open log file \"%s\": %s\n"),
+ progname, log_file, strerror(errno));
+ exit(1);
+ }
+ } else {
+ close(fd);
}
- fclose(fd);
snprintf(cmd, MAXPGPATH, "CMD /C \"\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1\"",
exec_path, pgdata_opt, post_opts, DEVNULL, log_file);