=== Applying patches on top of PostgreSQL commit ID 451c43974f8e199097d97624a4952ad0973cea61 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Jan 3 01:55:22 UTC 2026 On branch cf/4573 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Fix-pg_ctl-on-Windows-to-reliably-detect-already-run.patch === Applying: Fix pg_ctl on Windows to reliably detect already-running postmaster. Using index info to reconstruct a base tree... M src/bin/pg_ctl/pg_ctl.c Falling back to patching base and 3-way merge... Auto-merging src/bin/pg_ctl/pg_ctl.c CONFLICT (content): Merge conflict in src/bin/pg_ctl/pg_ctl.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Fix pg_ctl on Windows to reliably detect already-running postmaster. When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M src/bin/pg_ctl/pg_ctl.c === using patch(1) to apply patch ./v2-0001-Fix-pg_ctl-on-Windows-to-reliably-detect-already-run.patch === patching file src/bin/pg_ctl/pg_ctl.c Hunk #1 succeeded at 73 with fuzz 2 (offset 1 line). Hunk #2 succeeded at 101 (offset 1 line). Hunk #3 succeeded at 143 (offset 1 line). Hunk #4 succeeded at 424 (offset 1 line). Hunk #5 FAILED at 747. Hunk #6 succeeded at 866 (offset 1 line). Hunk #7 succeeded at 920 (offset 1 line). Hunk #8 succeeded at 931 (offset 1 line). Hunk #9 succeeded at 955 with fuzz 1 (offset 1 line). Hunk #10 succeeded at 1184 (offset 1 line). Hunk #11 succeeded at 1222 (offset 1 line). 1 out of 11 hunks FAILED -- saving rejects to file src/bin/pg_ctl/pg_ctl.c.rej Unstaged changes after reset: M src/bin/pg_ctl/pg_ctl.c Removing src/bin/pg_ctl/pg_ctl.c.rej === using 'git apply' to apply patch ./v2-0001-Fix-pg_ctl-on-Windows-to-reliably-detect-already-run.patch === Applied patch to 'src/bin/pg_ctl/pg_ctl.c' with conflicts. U src/bin/pg_ctl/pg_ctl.c diff --cc src/bin/pg_ctl/pg_ctl.c index 122856b599e,15db41a6c1b..00000000000 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@@ -69,10 -68,11 +69,11 @@@ typedef enu #define DEFAULT_WAIT 60 -#define USEC_PER_SEC 1000000 - -#define WAITS_PER_SEC 10 /* should divide USEC_PER_SEC evenly */ +#define WAITS_PER_SEC 10 +StaticAssertDecl(USECS_PER_SEC % WAITS_PER_SEC == 0, + "WAITS_PER_SEC must divide USECS_PER_SEC evenly"); + static pid_t pm_pid = 0; static bool do_wait = true; static int wait_seconds = DEFAULT_WAIT; static bool wait_seconds_arg = false; @@@ -521,56 -771,28 +772,34 @@@ start_postmaster(void if (log_file != NULL) { - /* - * First, open the log file if it exists. The idea is that if the - * file is still locked by a previous postmaster run, we'll wait until - * it comes free, instead of failing with ERROR_SHARING_VIOLATION. - * (It'd be better to open the file in a sharing-friendly mode, but we - * can't use CMD.EXE to do that, so work around it. Note that the - * previous postmaster will still have the file open for a short time - * after removing postmaster.pid.) - * - * If the log file doesn't exist, we *must not* create it here. If we - * were launched with higher privileges than the restricted process - * will have, the log file might end up with permissions settings that - * prevent the postmaster from writing on it. - */ - int fd = open(log_file, O_RDWR, 0); - - if (fd == -1) - { - /* - * ENOENT is expectable since we didn't use O_CREAT. Otherwise - * complain. We could just fall through and let CMD.EXE report - * the problem, but its error reporting is pretty miserable. - */ - if (errno != ENOENT) - { - write_stderr(_("%s: could not open log file \"%s\": %m\n"), - progname, log_file); - exit(1); - } - } - else - close(fd); - - cmd = psprintf("\"%s\" /C \"\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1\"", - comspec, exec_path, pgdata_opt, post_opts, DEVNULL, log_file); + snprintf(cmd, cmdlen + 1, "exec \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1", + exec_path, + pgdata_opt ? pgdata_opt : "", + post_opts ? post_opts : "", + DEVNULL, log_file); } else - cmd = psprintf("\"%s\" /C \"\"%s\" %s%s < \"%s\" 2>&1\"", - comspec, exec_path, pgdata_opt, post_opts, DEVNULL); - - if (!CreateRestrictedProcess(cmd, &pi, false)) { ++<<<<<<< ours + write_stderr(_("%s: could not start server: error code %lu\n"), + progname, GetLastError()); + exit(1); ++======= + snprintf(cmd, cmdlen + 1, "exec \"%s\" %s%s < \"%s\" 2>&1", + exec_path, + pgdata_opt ? pgdata_opt : "", + post_opts ? post_opts : "", + DEVNULL); ++>>>>>>> theirs } - /* Don't close command process handle here; caller must do so */ - postmasterProcess = pi.hProcess; - CloseHandle(pi.hThread); - return pi.dwProcessId; /* Shell's PID, not postmaster's! */ + + (void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL); + + /* exec failed */ + write_stderr(_("%s: could not start server: %m\n"), + progname); + exit(1); + #endif /* WIN32 */ } @@@ -700,10 -911,10 +918,10 @@@ wait_for_postmaster_start(pid_t pm_pid print_msg("."); } - pg_usleep(USEC_PER_SEC / WAITS_PER_SEC); + pg_usleep(USECS_PER_SEC / WAITS_PER_SEC); } - /* out of patience; report that postmaster is still starting up */ + /* Ran out of time */ return POSTMASTER_STILL_STARTING; }