]> granicus.if.org Git - postgresql/commitdiff
Restructure child-exit logging messages for easier translation,
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Nov 2001 23:06:12 +0000 (23:06 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 10 Nov 2001 23:06:12 +0000 (23:06 +0000)
per suggestion from Peter.

src/backend/postmaster/postmaster.c

index 2622ee082153962afcae550aa3fc7bd5db009a60..67f066515b427ae7fee6668da685dcf0b288be98 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.258 2001/11/06 18:02:48 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.259 2001/11/10 23:06:12 tgl Exp $
  *
  * NOTES
  *
@@ -240,7 +240,7 @@ static void reaper(SIGNAL_ARGS);
 static void sigusr1_handler(SIGNAL_ARGS);
 static void dummy_handler(SIGNAL_ARGS);
 static void CleanupProc(int pid, int exitstatus);
-static const char *formatExitStatus(int exitstatus);
+static void LogChildExit(const char *procname, int pid, int exitstatus);
 static int     DoBackend(Port *port);
 static void ExitPostmaster(int status);
 static void usage(const char *);
@@ -1544,8 +1544,8 @@ reaper(SIGNAL_ARGS)
                 */
                if (pgstat_ispgstat(pid))
                {
-                       elog(DEBUG, "statistics collector process (pid %d) %s",
-                                pid, formatExitStatus(exitstatus));
+                       LogChildExit(gettext("statistics collector process"),
+                                                pid, exitstatus);
                        pgstat_start();
                        continue;
                }
@@ -1557,8 +1557,8 @@ reaper(SIGNAL_ARGS)
                {
                        if (exitstatus != 0)
                        {
-                               elog(DEBUG, "shutdown process (pid %d) %s",
-                                        pid, formatExitStatus(exitstatus));
+                               LogChildExit(gettext("shutdown process"),
+                                                        pid, exitstatus);
                                ExitPostmaster(1);
                        }
                        ExitPostmaster(0);
@@ -1568,8 +1568,9 @@ reaper(SIGNAL_ARGS)
                {
                        if (exitstatus != 0)
                        {
-                               elog(DEBUG, "startup process (pid %d) %s; aborting startup",
-                                        pid, formatExitStatus(exitstatus));
+                               LogChildExit(gettext("startup process"),
+                                                        pid, exitstatus);
+                               elog(DEBUG, "aborting startup due to startup process failure");
                                ExitPostmaster(1);
                        }
                        StartupPID = 0;
@@ -1639,8 +1640,6 @@ reaper_done:
  * CleanupProc -- cleanup after terminated backend.
  *
  * Remove all local state associated with backend.
- *
- * Dillon's note: should log child's exit status in the system log.
  */
 static void
 CleanupProc(int pid,
@@ -1651,8 +1650,7 @@ CleanupProc(int pid,
        Backend    *bp;
 
        if (DebugLvl)
-               elog(DEBUG, "CleanupProc: child process (pid %d) %s",
-                        pid, formatExitStatus(exitstatus));
+               LogChildExit(gettext("child process"), pid, exitstatus);
 
        /*
         * If a backend dies in an ugly way (i.e. exit status not 0) then we
@@ -1697,8 +1695,7 @@ CleanupProc(int pid,
        /* Make log entry unless we did so already */
        if (!FatalError)
        {
-               elog(DEBUG, "server process (pid %d) %s",
-                        pid, formatExitStatus(exitstatus));
+               LogChildExit(gettext("server process"), pid, exitstatus);
                elog(DEBUG, "terminating any other active server processes");
        }
 
@@ -1756,33 +1753,24 @@ CleanupProc(int pid,
 }
 
 /*
- * Convert a wait(2) exit status into a printable string.
- *
- * For present uses, it's okay to use a static return area here.
+ * Log the death of a child process.
  */
-static const char *
-formatExitStatus(int exitstatus)
+static void
+LogChildExit(const char *procname, int pid, int exitstatus)
 {
-       static char result[100];
-
        /*
-        * translator: these strings provide the verb phrase in the preceding
-        * messages such as "server process (pid %d) %s"
+        * translator: the first %s in these messages is a noun phrase
+        * describing a child process, such as "server process"
         */
        if (WIFEXITED(exitstatus))
-               snprintf(result, sizeof(result),
-                                gettext("exited with exit code %d"),
-                                WEXITSTATUS(exitstatus));
+               elog(DEBUG, "%s (pid %d) exited with exit code %d",
+                        procname, pid, WEXITSTATUS(exitstatus));
        else if (WIFSIGNALED(exitstatus))
-               snprintf(result, sizeof(result),
-                                gettext("was terminated by signal %d"),
-                                WTERMSIG(exitstatus));
+               elog(DEBUG, "%s (pid %d) was terminated by signal %d",
+                        procname, pid, WTERMSIG(exitstatus));
        else
-               snprintf(result, sizeof(result),
-                                gettext("exited with unexpected status %d"),
-                                exitstatus);
-
-       return result;
+               elog(DEBUG, "%s (pid %d) exited with unexpected status %d",
+                        procname, pid, exitstatus);
 }
 
 /*