From 23ad2d32cabab60e721540eb4c7668ce93e3f6b4 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 27 Jun 2008 01:53:09 +0000 Subject: [PATCH] Fix 'pg_ctl reload' to properly preserve postmaster commend-line arguments on restart. Patch to releases 8.0 - 8.3.X. --- src/backend/postmaster/postmaster.c | 2 +- src/bin/pg_ctl/pg_ctl.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 5aa0393799..2ef5301a19 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3640,7 +3640,7 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname) fprintf(fp, "%s", fullprogname); for (i = 1; i < argc; i++) - fprintf(fp, " %s%s%s", SYSTEMQUOTE, argv[i], SYSTEMQUOTE); + fprintf(fp, " \"%s\"", argv[i]); fputs("\n", fp); if (fclose(fp)) diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 88de8f78f9..7844777362 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -537,15 +537,18 @@ do_start(void) { char *arg1; - arg1 = strchr(optline, *SYSTEMQUOTE); - if (arg1 == NULL || arg1 == optline) - post_opts = ""; - else + /* + * Are we at the first option, as defined by space and + * double-quote? + */ + if ((arg1 = strstr(optline, " \"")) != NULL || + /* check in case this is an older server */ + (arg1 = strstr(optline, " -")) != NULL) { - *(arg1 - 1) = '\0'; /* this should be a space */ - post_opts = arg1; + *arg1 = '\0'; /* terminate so we get only program name */ + post_opts = arg1 + 1; /* point past whitespace */ } - if (postgres_path != NULL) + if (postgres_path == NULL) postgres_path = optline; } else -- 2.39.5