Revert "Hack pg_ctl to report postmaster's exit status."
This reverts commit 6a5084eed4
.
We learned what we needed to know from that.
This commit is contained in:
parent
1df5875d39
commit
f38291e927
|
@ -106,7 +106,6 @@ static char promote_file[MAXPGPATH];
|
||||||
static char logrotate_file[MAXPGPATH];
|
static char logrotate_file[MAXPGPATH];
|
||||||
|
|
||||||
static volatile pgpid_t postmasterPID = -1;
|
static volatile pgpid_t postmasterPID = -1;
|
||||||
static pgpid_t old_postmaster_pid = 0;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static DWORD pgctl_start_type = SERVICE_AUTO_START;
|
static DWORD pgctl_start_type = SERVICE_AUTO_START;
|
||||||
|
@ -486,17 +485,16 @@ start_postmaster(void)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since there might be quotes to handle here, it is easier simply to pass
|
* Since there might be quotes to handle here, it is easier simply to pass
|
||||||
* everything to a shell to process them.
|
* everything to a shell to process them. Use exec so that the postmaster
|
||||||
*
|
* has the same PID as the current child process.
|
||||||
* Since we aren't telling the shell to directly exec the postmaster,
|
|
||||||
* the returned PID is a parent process, the same as on Windows.
|
|
||||||
*/
|
*/
|
||||||
if (log_file != NULL)
|
if (log_file != NULL)
|
||||||
snprintf(cmd, MAXPGPATH, "exec < \"%s\" >> \"%s\" 2>&1; \"%s\" %s%s; echo postmaster exit status is $?",
|
snprintf(cmd, MAXPGPATH, "exec \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1",
|
||||||
DEVNULL, log_file, exec_path, pgdata_opt, post_opts);
|
exec_path, pgdata_opt, post_opts,
|
||||||
|
DEVNULL, log_file);
|
||||||
else
|
else
|
||||||
snprintf(cmd, MAXPGPATH, "exec < \"%s\" 2>&1; \"%s\" %s%s; echo postmaster exit status is $?",
|
snprintf(cmd, MAXPGPATH, "exec \"%s\" %s%s < \"%s\" 2>&1",
|
||||||
DEVNULL, exec_path, pgdata_opt, post_opts);
|
exec_path, pgdata_opt, post_opts, DEVNULL);
|
||||||
|
|
||||||
(void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL);
|
(void) execl("/bin/sh", "/bin/sh", "-c", cmd, (char *) NULL);
|
||||||
|
|
||||||
|
@ -583,8 +581,12 @@ wait_for_postmaster(pgpid_t pm_pid, bool do_checkpoint)
|
||||||
pmpid = atol(optlines[LOCK_FILE_LINE_PID - 1]);
|
pmpid = atol(optlines[LOCK_FILE_LINE_PID - 1]);
|
||||||
pmstart = atol(optlines[LOCK_FILE_LINE_START_TIME - 1]);
|
pmstart = atol(optlines[LOCK_FILE_LINE_START_TIME - 1]);
|
||||||
if (pmstart >= start_time - 2 &&
|
if (pmstart >= start_time - 2 &&
|
||||||
/* If pid is the value we saw before starting, assume it's stale */
|
#ifndef WIN32
|
||||||
pmpid > 0 && pmpid != old_postmaster_pid
|
pmpid == pm_pid
|
||||||
|
#else
|
||||||
|
/* Windows can only reject standalone-backend PIDs */
|
||||||
|
pmpid > 0
|
||||||
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -614,7 +616,7 @@ wait_for_postmaster(pgpid_t pm_pid, bool do_checkpoint)
|
||||||
* Check whether the child postmaster process is still alive. This
|
* Check whether the child postmaster process is still alive. This
|
||||||
* lets us exit early if the postmaster fails during startup.
|
* lets us exit early if the postmaster fails during startup.
|
||||||
*
|
*
|
||||||
* We may be checking the postmaster's parent shell, but
|
* On Windows, we may be checking the postmaster's parent shell, but
|
||||||
* that's fine for this purpose.
|
* that's fine for this purpose.
|
||||||
*/
|
*/
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -816,12 +818,13 @@ do_init(void)
|
||||||
static void
|
static void
|
||||||
do_start(void)
|
do_start(void)
|
||||||
{
|
{
|
||||||
|
pgpid_t old_pid = 0;
|
||||||
pgpid_t pm_pid;
|
pgpid_t pm_pid;
|
||||||
|
|
||||||
if (ctl_command != RESTART_COMMAND)
|
if (ctl_command != RESTART_COMMAND)
|
||||||
{
|
{
|
||||||
old_postmaster_pid = get_pgpid(false);
|
old_pid = get_pgpid(false);
|
||||||
if (old_postmaster_pid != 0)
|
if (old_pid != 0)
|
||||||
write_stderr(_("%s: another server might be running; "
|
write_stderr(_("%s: another server might be running; "
|
||||||
"trying to start server anyway\n"),
|
"trying to start server anyway\n"),
|
||||||
progname);
|
progname);
|
||||||
|
|
Loading…
Reference in New Issue