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}
490490else if (optlines [0 ]== NULL || optlines [1 ]!= NULL )
491491{
492- write_stderr (_ ("%s: option file \"%s\" must have exactly1 line\n" ),
492+ write_stderr (_ ("%s: option file \"%s\" must have exactlyone line\n" ),
493493progname ,ctl_command == RESTART_COMMAND ?
494494postopts_file :def_postopts_file );
495495exit (1 );
@@ -583,7 +583,10 @@ do_start(void)
583583if (test_postmaster_connection ()== false)
584584printf (_ ("could not start postmaster\n" ));
585585else
586- print_msg (_ (" done\npostmaster started\n" ));
586+ {
587+ print_msg (_ (" done\n" ));
588+ print_msg (_ ("postmaster started\n" ));
589+ }
587590}
588591else
589592print_msg (_ ("postmaster starting\n" ));
@@ -669,7 +672,8 @@ do_restart(void)
669672if (pid == 0 )/* no pid file */
670673{
671674write_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" ));
673677do_start ();
674678return ;
675679}
@@ -743,8 +747,8 @@ do_reload(void)
743747
744748if (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 ));
748752exit (1 );
749753}
750754
@@ -763,7 +767,7 @@ do_status(void)
763767pid = get_pgpid ();
764768if (pid == 0 )/* no pid file */
765769{
766- write_stderr (_ ("%s: postmasteror postgres not running\n" ),progname );
770+ write_stderr (_ ("%s:neither postmasternor postgres running\n" ),progname );
767771exit (1 );
768772}
769773else if (pid < 0 )/* standalone backend */
@@ -818,13 +822,22 @@ pgwin32_CommandLine(bool registration)
818822int ret ;
819823
820824if (registration )
825+ {
821826ret = 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+ }
822833else
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
830843if (registration )
@@ -887,7 +900,7 @@ pgwin32_doRegister(void)
887900NULL ,NULL ,"RPCSS\0" ,register_username ,register_password ))== NULL )
888901{
889902CloseServiceHandle (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 ());
891904exit (1 );
892905}
893906CloseServiceHandle (hService );
@@ -915,14 +928,14 @@ pgwin32_doUnregister(void)
915928if ((hService = OpenService (hSCM ,register_servicename ,DELETE ))== NULL )
916929{
917930CloseServiceHandle (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 ());
919932exit (1 );
920933}
921934if (!DeleteService (hService ))
922935{
923936CloseServiceHandle (hService );
924937CloseServiceHandle (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 ());
926939exit (1 );
927940}
928941CloseServiceHandle (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{
10701083printf (_ ("%s is a utility to start, stop, restart, reload configuration files,\n"
1071- "report the status of a PostgreSQL server, orkill a PostgreSQL process\n\n" ),progname );
1084+ "report the status of a PostgreSQL server, orsignal a PostgreSQL process. \n\n" ),progname );
10721085printf (_ ("Usage:\n" ));
10731086printf (_ (" %s start [-w] [-D DATADIR] [-s] [-l FILENAME] [-o \"OPTIONS\"]\n" ),progname );
10741087printf (_ (" %s stop [-W] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]\n" ),progname );
10751088printf (_ (" %s restart [-w] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o \"OPTIONS\"]\n" ),progname );
10761089printf (_ (" %s reload [-D DATADIR] [-s]\n" ),progname );
10771090printf (_ (" %s status [-D DATADIR]\n" ),progname );
1078- printf (_ (" %s kill SIGNALNAMEPROCESSID \n" ),progname );
1091+ printf (_ (" %s kill SIGNALNAMEPID \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 );
10811095printf (_ (" %s unregister [-N SERVICENAME]\n" ),progname );
10821096#endif
1083- printf (_ ("Common options:\n" ));
1097+
1098+ printf (_ ("\nCommon options:\n" ));
10841099printf (_ (" -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" ));
10951105printf (_ ("(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 ( orappend) 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 orrestart: \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 orrestart: \n" ));
1115+ printf (_ (" -m SHUTDOWN-MODE may be \"smart\", \"fast\", or \"immediate\" \n" ));
1116+
1117+ printf (_ ("\nShutdown modes are:\n" ));
11081118printf (_ (" smart quit after all clients have disconnected\n" ));
11091119printf (_ (" 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{
13131334if (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 ]);
13161337do_advice ();
13171338exit (1 );
13181339}
@@ -1331,7 +1352,7 @@ main(int argc, char **argv)
13311352{
13321353if (argc - optind < 3 )
13331354{
1334- write_stderr (_ ("%s:invalid killsyntax \n" ),progname );
1355+ write_stderr (_ ("%s:missing arguments for killmode \n" ),progname );
13351356do_advice ();
13361357exit (1 );
13371358}