postgres.git / summary / log / commit / refs

commit    336bc0dff20e47344337a99a3aeba9e2e5385af0
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Thu Nov 22 16:23:46 2012 +0000

    Fix pg_resetxlog to use correct path to postmaster.pid.
    
    Since we've already chdir'd into the data directory, the file should
    be referenced as just "postmaster.pid", without prefixing the directory
    path.  This is harmless in the normal case where an absolute PGDATA path
    is used, but quite dangerous if a relative path is specified, since the
    program might then fail to notice an active postmaster.
    
    Reported by Hari Babu.  This got broken in my commit
    eb5949d190e80360386113fde0f05854f0c9824d, so patch all active versions.


src/bin/pg_resetxlog/pg_resetxlog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 9ce7e6d6597..fceebbbd2a6 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -87,7 +87,6 @@ main(int argc, char *argv[]) char *endptr3; char *DataDir; int fd; - char path[MAXPGPATH]; set_pglocale_pgservice(argv[0], "pg_resetxlog"); @@ -262,13 +261,12 @@ main(int argc, char *argv[]) * Check for a postmaster lock file --- if there is one, refuse to * proceed, on grounds we might be interfering with a live installation. */ - snprintf(path, MAXPGPATH, "%s/postmaster.pid", DataDir); - - if ((fd = open(path, O_RDONLY, 0)) < 0) + if ((fd = open("postmaster.pid", O_RDONLY, 0)) < 0) { if (errno != ENOENT) { - fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, path, strerror(errno)); + fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), + progname, "postmaster.pid", strerror(errno)); exit(1); } } @@ -276,7 +274,7 @@ main(int argc, char *argv[]) { fprintf(stderr, _("%s: lock file \"%s\" exists\n" "Is a server running? If not, delete the lock file and try again.\n"), - progname, path); + progname, "postmaster.pid"); exit(1); } [parent: 3352e25e85b2]