From 3c2ab01329157a05789994341627afce803a2080 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 27 Jun 2008 01:53:20 +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 f3fc485512..7d0e6d0889 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3762,7 +3762,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 d9366ba3ff..e29710f6e4 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -578,15 +578,18 @@ read_post_opts(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