44 *
55 * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66 *
7- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.40 2004/10/16 03:32:08 momjian Exp $
7+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.41 2004/10/19 13:38:53 petere Exp $
88 *
99 *-------------------------------------------------------------------------
1010 */
@@ -489,7 +489,7 @@ do_start(void)
489489 }
490490 else if (optlines [0 ] == NULL || optlines [1 ] != NULL )
491491 {
492- write_stderr (_ ("%s: option file \"%s\" must have exactly 1 line\n" ),
492+ write_stderr (_ ("%s: option file \"%s\" must have exactly one line\n" ),
493493 progname , ctl_command == RESTART_COMMAND ?
494494 postopts_file : def_postopts_file );
495495 exit (1 );
@@ -583,7 +583,10 @@ do_start(void)
583583 if (test_postmaster_connection () == false)
584584 printf (_ ("could not start postmaster\n" ));
585585 else
586- print_msg (_ (" done\npostmaster started\n" ));
586+ {
587+ print_msg (_ (" done\n" ));
588+ print_msg (_ ("postmaster started\n" ));
589+ }
587590 }
588591 else
589592 print_msg (_ ("postmaster starting\n" ));
@@ -669,7 +672,8 @@ do_restart(void)
669672 if (pid == 0 ) /* no pid file */
670673 {
671674 write_stderr (_ ("%s: PID file \"%s\" does not exist\n" ), progname , pid_file );
672- write_stderr (_ ("Is postmaster running?\nstarting postmaster anyway\n" ));
675+ write_stderr (_ ("Is postmaster running?\n" ));
676+ write_stderr (_ ("starting postmaster anyway\n" ));
673677 do_start ();
674678 return ;
675679 }
@@ -743,8 +747,8 @@ do_reload(void)
743747
744748 if (kill ((pid_t ) pid , sig ) != 0 )
745749 {
746- write_stderr (_ ("could not send reload signal (PID: %ld): %s\n" ), pid ,
747- strerror (errno ));
750+ write_stderr (_ ("%s: could not send reload signal (PID: %ld): %s\n" ),
751+ progname , pid , strerror (errno ));
748752 exit (1 );
749753 }
750754
@@ -763,7 +767,7 @@ do_status(void)
763767 pid = get_pgpid ();
764768 if (pid == 0 ) /* no pid file */
765769 {
766- write_stderr (_ ("%s: postmaster or postgres not running\n" ), progname );
770+ write_stderr (_ ("%s: neither postmaster nor postgres running\n" ), progname );
767771 exit (1 );
768772 }
769773 else if (pid < 0 ) /* standalone backend */
@@ -818,13 +822,22 @@ pgwin32_CommandLine(bool registration)
818822 int ret ;
819823
820824 if (registration )
825+ {
821826 ret = find_my_exec (argv0 , cmdLine );
827+ if (ret != 0 )
828+ {
829+ write_stderr (_ ("%s: could not find own program executable\n" ), progname );
830+ exit (1 );
831+ }
832+ }
822833 else
823- ret = find_other_exec (argv0 , "postmaster" , PM_VERSIONSTR , cmdLine );
824- if (ret != 0 )
825834 {
826- write_stderr (_ ("%s: could not find exe" ), progname );
827- exit (1 );
835+ ret = find_other_exec (argv0 , "postmaster" , PM_VERSIONSTR , cmdLine );
836+ if (ret != 0 )
837+ {
838+ write_stderr (_ ("%s: could not find postmaster program executable\n" ), progname );
839+ exit (1 );
840+ }
828841 }
829842
830843 if (registration )
@@ -887,7 +900,7 @@ pgwin32_doRegister(void)
887900 NULL , NULL , "RPCSS\0" , register_username , register_password )) == NULL )
888901 {
889902 CloseServiceHandle (hSCM );
890- write_stderr (_ ("%s: could not register service \"%s\" [%d] \n" ), progname , register_servicename , (int ) GetLastError ());
903+ write_stderr (_ ("%s: could not register service \"%s\": error code %d \n" ), progname , register_servicename , (int ) GetLastError ());
891904 exit (1 );
892905 }
893906 CloseServiceHandle (hService );
@@ -915,14 +928,14 @@ pgwin32_doUnregister(void)
915928 if ((hService = OpenService (hSCM , register_servicename , DELETE )) == NULL )
916929 {
917930 CloseServiceHandle (hSCM );
918- write_stderr (_ ("%s: could not open service \"%s\" [%d] \n" ), progname , register_servicename , (int ) GetLastError ());
931+ write_stderr (_ ("%s: could not open service \"%s\": error code %d \n" ), progname , register_servicename , (int ) GetLastError ());
919932 exit (1 );
920933 }
921934 if (!DeleteService (hService ))
922935 {
923936 CloseServiceHandle (hService );
924937 CloseServiceHandle (hSCM );
925- write_stderr (_ ("%s: could not unregister service \"%s\" [%d] \n" ), progname , register_servicename , (int ) GetLastError ());
938+ write_stderr (_ ("%s: could not unregister service \"%s\": error code %d \n" ), progname , register_servicename , (int ) GetLastError ());
926939 exit (1 );
927940 }
928941 CloseServiceHandle (hService );
@@ -1059,7 +1072,7 @@ pgwin32_doRunAsService(void)
10591072static void
10601073do_advice (void )
10611074{
1062- write_stderr (_ ("\nTry \"%s --help\" for more information.\n" ), progname );
1075+ write_stderr (_ ("Try \"%s --help\" for more information.\n" ), progname );
10631076}
10641077
10651078
@@ -1068,47 +1081,55 @@ static void
10681081do_help (void )
10691082{
10701083 printf (_ ("%s is a utility to start, stop, restart, reload configuration files,\n"
1071- "report the status of a PostgreSQL server, or kill a PostgreSQL process\n\n" ), progname );
1084+ "report the status of a PostgreSQL server, or signal a PostgreSQL process. \n\n" ), progname );
10721085 printf (_ ("Usage:\n" ));
10731086 printf (_ (" %s start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]\n" ), progname );
10741087 printf (_ (" %s stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n" ), progname );
10751088 printf (_ (" %s restart [-w] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"]\n" ), progname );
10761089 printf (_ (" %s reload [-D DATADIR] [-s]\n" ), progname );
10771090 printf (_ (" %s status [-D DATADIR]\n" ), progname );
1078- printf (_ (" %s kill SIGNALNAME PROCESSID \n" ), progname );
1091+ printf (_ (" %s kill SIGNALNAME PID \n" ), progname );
10791092#if defined(WIN32 ) || defined(__CYGWIN__ )
1080- printf (_ (" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR] [-w] [-o \"OPTIONS\"]\n" ), progname );
1093+ printf (_ (" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
1094+ " [-w] [-o \"OPTIONS\"]\n" ), progname );
10811095 printf (_ (" %s unregister [-N SERVICENAME]\n" ), progname );
10821096#endif
1083- printf (_ ("Common options:\n" ));
1097+
1098+ printf (_ ("\nCommon options:\n" ));
10841099 printf (_ (" -D, --pgdata DATADIR location of the database storage area\n" ));
1085- printf (_ (" -s, --silent only print errors, no informational messages\n" ));
1086- #if defined(WIN32 ) || defined(__CYGWIN__ )
1087- printf (_ (" -N service name with which to register PostgreSQL server\n" ));
1088- printf (_ (" -P password of account to register PostgreSQL server\n" ));
1089- printf (_ (" -U user name of account to register PostgreSQL server\n" ));
1090- #endif
1091- printf (_ (" -w wait until operation completes\n" ));
1092- printf (_ (" -W do not wait until operation completes\n" ));
1093- printf (_ (" --help show this help, then exit\n" ));
1094- printf (_ (" --version output version information, then exit\n" ));
1100+ printf (_ (" -s, --silent only print errors, no informational messages\n" ));
1101+ printf (_ (" -w wait until operation completes\n" ));
1102+ printf (_ (" -W do not wait until operation completes\n" ));
1103+ printf (_ (" --help show this help, then exit\n" ));
1104+ printf (_ (" --version output version information, then exit\n" ));
10951105 printf (_ ("(The default is to wait for shutdown, but not for start or restart.)\n\n" ));
1096- printf (_ ("If the -D option is omitted, the environment variable PGDATA is used.\n\n " ));
1097- printf ( _ ( "Options for start or restart:\n" ));
1098- printf (_ (" -l, --log FILENAME write ( or append) server log to FILENAME. The \n"
1099- " use of this option is highly recommended. \n" ));
1100- printf (_ (" -o OPTIONS command line options to pass to the postmaster\n"
1101- " (PostgreSQL server executable)\n" ));
1102- printf (_ (" -p PATH-TO-POSTMASTER normally not necessary\n \n" ));
1103- printf ( _ ( "Options for stop or restart:\n" ));
1104- printf (_ (" -m SHUTDOWN-MODE may be \"smart\", \"fast\", or \"immediate\"\n \n" ));
1105- printf (_ ("Allowed signal names for kill: \n" ));
1106- printf ( _ ( " HUP INT QUIT ABRT TERM USR1 USR2\n\n" ));
1107- printf (_ ("Shutdown modes are:\n" ));
1106+ printf (_ ("If the -D option is omitted, the environment variable PGDATA is used.\n" ));
1107+
1108+ printf (_ ("\nOptions for start or restart: \n" ));
1109+ printf ( _ ( " -l, --log FILENAME write (or append) server log to FILENAME \n" ));
1110+ printf (_ (" -o OPTIONS command line options to pass to the postmaster\n"
1111+ " (PostgreSQL server executable)\n" ));
1112+ printf (_ (" -p PATH-TO-POSTMASTER normally not necessary\n" ));
1113+
1114+ printf (_ ("\nOptions for stop or restart: \n" ));
1115+ printf (_ (" -m SHUTDOWN-MODE may be \"smart\", \"fast\", or \"immediate\" \n" ));
1116+
1117+ printf (_ ("\nShutdown modes are:\n" ));
11081118 printf (_ (" smart quit after all clients have disconnected\n" ));
11091119 printf (_ (" fast quit directly, with proper shutdown\n" ));
1110- printf (_ (" immediate quit without complete shutdown; will lead to recovery on restart\n\n" ));
1111- printf (_ ("Report bugs to <pgsql-bugs@postgresql.org>.\n" ));
1120+ printf (_ (" immediate quit without complete shutdown; will lead to recovery on restart\n" ));
1121+
1122+ printf (_ ("\nAllowed signal names for kill:\n" ));
1123+ printf (" HUP INT QUIT ABRT TERM USR1 USR2\n" );
1124+
1125+ #if defined(WIN32 ) || defined(__CYGWIN__ )
1126+ printf (_ ("\nOptions for register and unregister:\n" ));
1127+ printf (_ (" -N SERVICENAME service name with which to register PostgreSQL server\n" ));
1128+ printf (_ (" -P PASSWORD password of account to register PostgreSQL server\n" ));
1129+ printf (_ (" -U USERNAME user name of account to register PostgreSQL server\n" ));
1130+ #endif
1131+
1132+ printf (_ ("\nReport bugs to <pgsql-bugs@postgresql.org>.\n" ));
11121133}
11131134
11141135
@@ -1312,7 +1333,7 @@ main(int argc, char **argv)
13121333 {
13131334 if (ctl_command != NO_COMMAND )
13141335 {
1315- write_stderr (_ ("%s: extra operation mode \"%s\"\n" ), progname , argv [optind ]);
1336+ write_stderr (_ ("%s: too many command-line arguments (first is \"%s\") \n" ), progname , argv [optind ]);
13161337 do_advice ();
13171338 exit (1 );
13181339 }
@@ -1331,7 +1352,7 @@ main(int argc, char **argv)
13311352 {
13321353 if (argc - optind < 3 )
13331354 {
1334- write_stderr (_ ("%s: invalid kill syntax \n" ), progname );
1355+ write_stderr (_ ("%s: missing arguments for kill mode \n" ), progname );
13351356 do_advice ();
13361357 exit (1 );
13371358 }
0 commit comments