37
37
*
38
38
*
39
39
* 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 $
41
41
*
42
42
* NOTES
43
43
*
@@ -240,7 +240,7 @@ static void reaper(SIGNAL_ARGS);
240
240
static void sigusr1_handler (SIGNAL_ARGS );
241
241
static void dummy_handler (SIGNAL_ARGS );
242
242
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 );
244
244
static int DoBackend (Port * port );
245
245
static void ExitPostmaster (int status );
246
246
static void usage (const char * );
@@ -1544,8 +1544,8 @@ reaper(SIGNAL_ARGS)
1544
1544
*/
1545
1545
if (pgstat_ispgstat (pid ))
1546
1546
{
1547
- elog ( DEBUG , "statistics collector process (pid %d) %s" ,
1548
- pid , formatExitStatus ( exitstatus ) );
1547
+ LogChildExit ( gettext ( "statistics collector process" ) ,
1548
+ pid , exitstatus );
1549
1549
pgstat_start ();
1550
1550
continue ;
1551
1551
}
@@ -1557,8 +1557,8 @@ reaper(SIGNAL_ARGS)
1557
1557
{
1558
1558
if (exitstatus != 0 )
1559
1559
{
1560
- elog ( DEBUG , "shutdown process (pid %d) %s" ,
1561
- pid , formatExitStatus ( exitstatus ) );
1560
+ LogChildExit ( gettext ( "shutdown process" ) ,
1561
+ pid , exitstatus );
1562
1562
ExitPostmaster (1 );
1563
1563
}
1564
1564
ExitPostmaster (0 );
@@ -1568,8 +1568,9 @@ reaper(SIGNAL_ARGS)
1568
1568
{
1569
1569
if (exitstatus != 0 )
1570
1570
{
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" );
1573
1574
ExitPostmaster (1 );
1574
1575
}
1575
1576
StartupPID = 0 ;
@@ -1639,8 +1640,6 @@ reaper(SIGNAL_ARGS)
1639
1640
* CleanupProc -- cleanup after terminated backend.
1640
1641
*
1641
1642
* Remove all local state associated with backend.
1642
- *
1643
- * Dillon's note: should log child's exit status in the system log.
1644
1643
*/
1645
1644
static void
1646
1645
CleanupProc (int pid ,
@@ -1651,8 +1650,7 @@ CleanupProc(int pid,
1651
1650
Backend * bp ;
1652
1651
1653
1652
if (DebugLvl )
1654
- elog (DEBUG , "CleanupProc: child process (pid %d) %s" ,
1655
- pid , formatExitStatus (exitstatus ));
1653
+ LogChildExit (gettext ("child process" ), pid , exitstatus );
1656
1654
1657
1655
/*
1658
1656
* If a backend dies in an ugly way (i.e. exit status not 0) then we
@@ -1697,8 +1695,7 @@ CleanupProc(int pid,
1697
1695
/* Make log entry unless we did so already */
1698
1696
if (!FatalError )
1699
1697
{
1700
- elog (DEBUG , "server process (pid %d) %s" ,
1701
- pid , formatExitStatus (exitstatus ));
1698
+ LogChildExit (gettext ("server process" ), pid , exitstatus );
1702
1699
elog (DEBUG , "terminating any other active server processes" );
1703
1700
}
1704
1701
@@ -1756,33 +1753,24 @@ CleanupProc(int pid,
1756
1753
}
1757
1754
1758
1755
/*
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.
1762
1757
*/
1763
- static const char *
1764
- formatExitStatus ( int exitstatus )
1758
+ static void
1759
+ LogChildExit ( const char * procname , int pid , int exitstatus )
1765
1760
{
1766
- static char result [100 ];
1767
-
1768
1761
/*
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"
1771
1764
*/
1772
1765
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 ));
1776
1768
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 ));
1780
1771
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 );
1786
1774
}
1787
1775
1788
1776
/*
0 commit comments