Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0c1669c

Browse files
committed
Restructure child-exit logging messages for easier translation,
per suggestion from Peter.
1 parent ec43888 commit 0c1669c

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

src/backend/postmaster/postmaster.c

+22-34
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.258 2001/11/06 18:02:48 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.259 2001/11/10 23:06:12 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -240,7 +240,7 @@ static void reaper(SIGNAL_ARGS);
240240
static void sigusr1_handler(SIGNAL_ARGS);
241241
static void dummy_handler(SIGNAL_ARGS);
242242
static void CleanupProc(int pid, int exitstatus);
243-
static const char *formatExitStatus(int exitstatus);
243+
static void LogChildExit(const char *procname, int pid, int exitstatus);
244244
static int DoBackend(Port *port);
245245
static void ExitPostmaster(int status);
246246
static void usage(const char *);
@@ -1544,8 +1544,8 @@ reaper(SIGNAL_ARGS)
15441544
*/
15451545
if (pgstat_ispgstat(pid))
15461546
{
1547-
elog(DEBUG, "statistics collector process (pid %d) %s",
1548-
pid, formatExitStatus(exitstatus));
1547+
LogChildExit(gettext("statistics collector process"),
1548+
pid, exitstatus);
15491549
pgstat_start();
15501550
continue;
15511551
}
@@ -1557,8 +1557,8 @@ reaper(SIGNAL_ARGS)
15571557
{
15581558
if (exitstatus != 0)
15591559
{
1560-
elog(DEBUG, "shutdown process (pid %d) %s",
1561-
pid, formatExitStatus(exitstatus));
1560+
LogChildExit(gettext("shutdown process"),
1561+
pid, exitstatus);
15621562
ExitPostmaster(1);
15631563
}
15641564
ExitPostmaster(0);
@@ -1568,8 +1568,9 @@ reaper(SIGNAL_ARGS)
15681568
{
15691569
if (exitstatus != 0)
15701570
{
1571-
elog(DEBUG, "startup process (pid %d) %s; aborting startup",
1572-
pid, formatExitStatus(exitstatus));
1571+
LogChildExit(gettext("startup process"),
1572+
pid, exitstatus);
1573+
elog(DEBUG, "aborting startup due to startup process failure");
15731574
ExitPostmaster(1);
15741575
}
15751576
StartupPID = 0;
@@ -1639,8 +1640,6 @@ reaper(SIGNAL_ARGS)
16391640
* CleanupProc -- cleanup after terminated backend.
16401641
*
16411642
* Remove all local state associated with backend.
1642-
*
1643-
* Dillon's note: should log child's exit status in the system log.
16441643
*/
16451644
static void
16461645
CleanupProc(int pid,
@@ -1651,8 +1650,7 @@ CleanupProc(int pid,
16511650
Backend *bp;
16521651

16531652
if (DebugLvl)
1654-
elog(DEBUG, "CleanupProc: child process (pid %d) %s",
1655-
pid, formatExitStatus(exitstatus));
1653+
LogChildExit(gettext("child process"), pid, exitstatus);
16561654

16571655
/*
16581656
* If a backend dies in an ugly way (i.e. exit status not 0) then we
@@ -1697,8 +1695,7 @@ CleanupProc(int pid,
16971695
/* Make log entry unless we did so already */
16981696
if (!FatalError)
16991697
{
1700-
elog(DEBUG, "server process (pid %d) %s",
1701-
pid, formatExitStatus(exitstatus));
1698+
LogChildExit(gettext("server process"), pid, exitstatus);
17021699
elog(DEBUG, "terminating any other active server processes");
17031700
}
17041701

@@ -1756,33 +1753,24 @@ CleanupProc(int pid,
17561753
}
17571754

17581755
/*
1759-
* Convert a wait(2) exit status into a printable string.
1760-
*
1761-
* For present uses, it's okay to use a static return area here.
1756+
* Log the death of a child process.
17621757
*/
1763-
static const char *
1764-
formatExitStatus(int exitstatus)
1758+
static void
1759+
LogChildExit(const char *procname, int pid, int exitstatus)
17651760
{
1766-
static char result[100];
1767-
17681761
/*
1769-
* translator: these strings provide the verb phrase in the preceding
1770-
* messages such as "server process (pid %d) %s"
1762+
* translator: the first %s in these messages is a noun phrase
1763+
* describing a child process, such as "server process"
17711764
*/
17721765
if (WIFEXITED(exitstatus))
1773-
snprintf(result, sizeof(result),
1774-
gettext("exited with exit code %d"),
1775-
WEXITSTATUS(exitstatus));
1766+
elog(DEBUG, "%s (pid %d) exited with exit code %d",
1767+
procname, pid, WEXITSTATUS(exitstatus));
17761768
else if (WIFSIGNALED(exitstatus))
1777-
snprintf(result, sizeof(result),
1778-
gettext("was terminated by signal %d"),
1779-
WTERMSIG(exitstatus));
1769+
elog(DEBUG, "%s (pid %d) was terminated by signal %d",
1770+
procname, pid, WTERMSIG(exitstatus));
17801771
else
1781-
snprintf(result, sizeof(result),
1782-
gettext("exited with unexpected status %d"),
1783-
exitstatus);
1784-
1785-
return result;
1772+
elog(DEBUG, "%s (pid %d) exited with unexpected status %d",
1773+
procname, pid, exitstatus);
17861774
}
17871775

17881776
/*

0 commit comments

Comments
 (0)