On Thu, 2004-10-14 at 15:09, Neil Conway wrote: > This patch makes a couple small changes to pg_ctl [...]
A slightly revised version of the patch was applied to HEAD; the revised patch is attached. -Neil
Index: src/bin/pg_ctl/pg_ctl.c =================================================================== RCS file: /var/lib/cvs/pgsql/src/bin/pg_ctl/pg_ctl.c,v retrieving revision 1.35 diff -c -r1.35 pg_ctl.c *** src/bin/pg_ctl/pg_ctl.c 13 Oct 2004 10:35:05 -0000 1.35 --- src/bin/pg_ctl/pg_ctl.c 15 Oct 2004 01:32:08 -0000 *************** *** 66,72 **** static bool do_wait = false; static bool wait_set = false; static int wait_seconds = 60; ! static bool silence_echo = false; static ShutdownMode shutdown_mode = SMART_MODE; static int sig = SIGTERM; /* default */ static CtlCommand ctl_command = NO_COMMAND; --- 66,72 ---- static bool do_wait = false; static bool wait_set = false; static int wait_seconds = 60; ! static bool silent_mode = false; static ShutdownMode shutdown_mode = SMART_MODE; static int sig = SIGTERM; /* default */ static CtlCommand ctl_command = NO_COMMAND; *************** *** 92,116 **** static void do_help(void); static void set_mode(char *modeopt); static void set_sig(char *signame); ! static void do_start(); static void do_stop(void); static void do_restart(void); static void do_reload(void); static void do_status(void); static void do_kill(pgpid_t pid); #if defined(WIN32) || defined(__CYGWIN__) static bool pgwin32_IsInstalled(SC_HANDLE); static char *pgwin32_CommandLine(bool); ! static void pgwin32_doRegister(); ! static void pgwin32_doUnregister(); static void pgwin32_SetServiceStatus(DWORD); static void WINAPI pgwin32_ServiceHandler(DWORD); static void WINAPI pgwin32_ServiceMain(DWORD, LPTSTR *); ! static void pgwin32_doRunAsService(); #endif static pgpid_t get_pgpid(void); ! static char **readfile(char *path); static int start_postmaster(void); static bool test_postmaster_connection(void); --- 92,117 ---- static void do_help(void); static void set_mode(char *modeopt); static void set_sig(char *signame); ! static void do_start(void); static void do_stop(void); static void do_restart(void); static void do_reload(void); static void do_status(void); static void do_kill(pgpid_t pid); + static void print_msg(const char *msg); #if defined(WIN32) || defined(__CYGWIN__) static bool pgwin32_IsInstalled(SC_HANDLE); static char *pgwin32_CommandLine(bool); ! static void pgwin32_doRegister(void); ! static void pgwin32_doUnregister(void); static void pgwin32_SetServiceStatus(DWORD); static void WINAPI pgwin32_ServiceHandler(DWORD); static void WINAPI pgwin32_ServiceMain(DWORD, LPTSTR *); ! static void pgwin32_doRunAsService(void); #endif static pgpid_t get_pgpid(void); ! static char **readfile(const char *path); static int start_postmaster(void); static bool test_postmaster_connection(void); *************** *** 201,207 **** } - static char * xstrdup(const char *s) { --- 202,207 ---- *************** *** 216,222 **** return result; } ! static pgpid_t get_pgpid(void) --- 216,234 ---- return result; } ! /* ! * Given an already-localized string, print it to stdout unless the ! * user has specified that no messages should be printed. ! */ ! static void ! print_msg(const char *msg) ! { ! if (!silent_mode) ! { ! fputs(msg, stdout); ! fflush(stdout); ! } ! } static pgpid_t get_pgpid(void) *************** *** 247,253 **** * get the lines from a text file - return NULL if file can't be opened */ static char ** ! readfile(char *path) { FILE *infile; int maxlength = 0, --- 259,265 ---- * get the lines from a text file - return NULL if file can't be opened */ static char ** ! readfile(const char *path) { FILE *infile; int maxlength = 0, *************** *** 281,287 **** maxlength = linelen; /* set up the result and the line buffer */ - result = (char **) xmalloc((nlines + 1) * sizeof(char *)); buffer = (char *) xmalloc(maxlength + 1); --- 293,298 ---- *************** *** 429,439 **** } else { ! if (!silence_echo) ! { ! printf("."); ! fflush(stdout); ! } pg_usleep(1000000); /* 1 sec */ } } --- 440,446 ---- } else { ! print_msg("."); pg_usleep(1000000); /* 1 sec */ } } *************** *** 563,585 **** if (do_wait) { ! if (!silence_echo) ! { ! printf(_("waiting for postmaster to start...")); ! fflush(stdout); ! } if (test_postmaster_connection() == false) printf(_("could not start postmaster\n")); ! else if (!silence_echo) ! printf(_("done\npostmaster started\n")); } ! else if (!silence_echo) ! printf(_("postmaster starting\n")); } - static void do_stop(void) { --- 570,587 ---- if (do_wait) { ! print_msg(_("waiting for postmaster to start...")); if (test_postmaster_connection() == false) printf(_("could not start postmaster\n")); ! else ! print_msg(_(" done\npostmaster started\n")); } ! else ! print_msg(_("postmaster starting\n")); } static void do_stop(void) { *************** *** 612,638 **** if (!do_wait) { ! if (!silence_echo) ! printf(_("postmaster shutting down\n")); return; } else { ! if (!silence_echo) ! { ! printf(_("waiting for postmaster to shut down... ")); ! fflush(stdout); ! } for (cnt = 0; cnt < wait_seconds; cnt++) { if ((pid = get_pgpid()) != 0) { ! if (!silence_echo) ! { ! printf("."); ! fflush(stdout); ! } pg_usleep(1000000); /* 1 sec */ } else --- 614,631 ---- if (!do_wait) { ! print_msg(_("postmaster shutting down\n")); return; } else { ! print_msg(_("waiting for postmaster to shut down...")); for (cnt = 0; cnt < wait_seconds; cnt++) { if ((pid = get_pgpid()) != 0) { ! print_msg("."); pg_usleep(1000000); /* 1 sec */ } else *************** *** 641,654 **** if (pid != 0) /* pid file still exists */ { ! if (!silence_echo) ! printf(_("failed\n")); write_stderr(_("%s: postmaster does not shut down\n"), progname); exit(1); } ! if (!silence_echo) ! printf(_("done\n")); printf(_("postmaster stopped\n")); } --- 634,645 ---- if (pid != 0) /* pid file still exists */ { ! print_msg(_(" failed\n")); write_stderr(_("%s: postmaster does not shut down\n"), progname); exit(1); } ! print_msg(_(" done\n")); printf(_("postmaster stopped\n")); } *************** *** 691,701 **** exit(1); } ! if (!silence_echo) ! { ! printf(_("waiting for postmaster to shut down...")); ! fflush(stdout); ! } /* always wait for restart */ --- 682,688 ---- exit(1); } ! print_msg(_("waiting for postmaster to shut down...")); /* always wait for restart */ *************** *** 703,713 **** { if ((pid = get_pgpid()) != 0) { ! if (!silence_echo) ! { ! printf("."); ! fflush(stdout); ! } pg_usleep(1000000); /* 1 sec */ } else --- 690,696 ---- { if ((pid = get_pgpid()) != 0) { ! print_msg("."); pg_usleep(1000000); /* 1 sec */ } else *************** *** 716,731 **** if (pid != 0) /* pid file still exists */ { ! if (!silence_echo) ! printf(_(" failed\n")); write_stderr(_("%s: postmaster does not shut down\n"), progname); exit(1); } ! if (!silence_echo) ! printf(_("done\n")); ! printf(_("postmaster stopped\n")); do_start(); } --- 699,711 ---- if (pid != 0) /* pid file still exists */ { ! print_msg(_(" failed\n")); write_stderr(_("%s: postmaster does not shut down\n"), progname); exit(1); } ! print_msg(_(" done\n")); printf(_("postmaster stopped\n")); do_start(); } *************** *** 760,767 **** exit(1); } ! if (!silence_echo) ! fprintf(stdout, _("postmaster signaled\n")); } /* --- 740,746 ---- exit(1); } ! print_msg(_("postmaster signaled\n")); } /* *************** *** 876,882 **** } static void ! pgwin32_doRegister() { SC_HANDLE hService; SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); --- 855,861 ---- } static void ! pgwin32_doRegister(void) { SC_HANDLE hService; SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); *************** *** 908,914 **** } static void ! pgwin32_doUnregister() { SC_HANDLE hService; SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); --- 887,893 ---- } static void ! pgwin32_doUnregister(void) { SC_HANDLE hService; SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); *************** *** 1060,1066 **** } static void ! pgwin32_doRunAsService() { SERVICE_TABLE_ENTRY st[] = {{register_servicename, pgwin32_ServiceMain}, {NULL, NULL}}; --- 1039,1045 ---- } static void ! pgwin32_doRunAsService(void) { SERVICE_TABLE_ENTRY st[] = {{register_servicename, pgwin32_ServiceMain}, {NULL, NULL}}; *************** *** 1287,1293 **** register_password = xstrdup(optarg); break; case 's': ! silence_echo = true; break; case 'U': if (strchr(optarg, '\\')) --- 1266,1272 ---- register_password = xstrdup(optarg); break; case 's': ! silent_mode = true; break; case 'U': if (strchr(optarg, '\\'))
---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings