]> granicus.if.org Git - postgresql/blobdiff - src/bin/pg_ctl/pg_ctl.c
Assorted message style improvements
[postgresql] / src / bin / pg_ctl / pg_ctl.c
index 329cc24dd6e67e4de895d29e53c71b8b82034f9f..72fc4c1abf6ae80b92aafea727c9f07d36d9efb3 100644 (file)
@@ -1170,7 +1170,7 @@ do_status(void)
                        }
                }
                else
-               /* must be a postmaster */
+                       /* must be a postmaster */
                {
                        if (postmaster_is_alive((pid_t) pid))
                        {
@@ -1188,9 +1188,12 @@ do_status(void)
                }
        }
        printf(_("%s: no server running\n"), progname);
+
        /*
-        * The Linux Standard Base Core Specification 3.1 says this should return '3'
-        * http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
+        * The Linux Standard Base Core Specification 3.1 says this should return
+        * '3'
+        * http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-ge
+        * neric/iniscrptact.html
         */
        exit(3);
 }
@@ -1765,10 +1768,10 @@ do_help(void)
        printf(_("  -D, --pgdata=DATADIR   location of the database storage area\n"));
        printf(_("  -s, --silent           only print errors, no informational messages\n"));
        printf(_("  -t, --timeout=SECS     seconds to wait when using -w option\n"));
+       printf(_("  -V, --version          output version information, then exit\n"));
        printf(_("  -w                     wait until operation completes\n"));
        printf(_("  -W                     do not wait until operation completes\n"));
-       printf(_("  --help                 show this help, then exit\n"));
-       printf(_("  --version              output version information, then exit\n"));
+       printf(_("  -?, --help             show this help, then exit\n"));
        printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n"));
        printf(_("If the -D option is omitted, the environment variable PGDATA is used.\n"));
 
@@ -1851,7 +1854,7 @@ set_sig(char *signame)
                sig = SIGABRT;
 #if 0
        /* probably should NOT provide SIGKILL */
-       else if (strcmp(signame,"KILL") == 0)
+       else if (strcmp(signame, "KILL") == 0)
                sig = SIGKILL;
 #endif
        else if (strcmp(signame, "TERM") == 0)
@@ -1894,9 +1897,15 @@ set_starttype(char *starttypeopt)
 static void
 adjust_data_dir(void)
 {
-       char            cmd[MAXPGPATH], filename[MAXPGPATH], *my_exec_path;
+       char            cmd[MAXPGPATH],
+                               filename[MAXPGPATH],
+                          *my_exec_path;
        FILE       *fd;
 
+       /* do nothing if we're working without knowledge of data dir */
+       if (pg_config == NULL)
+               return;
+
        /* If there is no postgresql.conf, it can't be a config-only dir */
        snprintf(filename, sizeof(filename), "%s/postgresql.conf", pg_config);
        if ((fd = fopen(filename, "r")) == NULL)
@@ -1926,7 +1935,7 @@ adjust_data_dir(void)
        fd = popen(cmd, "r");
        if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL)
        {
-               write_stderr(_("%s: cannot find the data directory using %s\n"), progname, my_exec_path);
+               write_stderr(_("%s: could not determine the data directory using command \"%s\"\n"), progname, cmd);
                exit(1);
        }
        pclose(fd);
@@ -2183,8 +2192,10 @@ main(int argc, char **argv)
                pg_data = xstrdup(pg_config);
        }
 
+       /* -D might point at config-only directory; if so find the real PGDATA */
        adjust_data_dir();
-       
+
+       /* Complain if -D needed and not provided */
        if (pg_config == NULL &&
                ctl_command != KILL_COMMAND && ctl_command != UNREGISTER_COMMAND)
        {