|
37 | 37 | * |
38 | 38 | * |
39 | 39 | * IDENTIFICATION |
40 | | - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.257 2001/11/05 17:46:27 momjian Exp $ |
| 40 | + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.258 2001/11/06 18:02:48 tgl Exp $ |
41 | 41 | * |
42 | 42 | * NOTES |
43 | 43 | * |
@@ -240,6 +240,7 @@ static void reaper(SIGNAL_ARGS); |
240 | 240 | staticvoidsigusr1_handler(SIGNAL_ARGS); |
241 | 241 | staticvoiddummy_handler(SIGNAL_ARGS); |
242 | 242 | staticvoidCleanupProc(intpid,intexitstatus); |
| 243 | +staticconstchar*formatExitStatus(intexitstatus); |
243 | 244 | staticintDoBackend(Port*port); |
244 | 245 | staticvoidExitPostmaster(intstatus); |
245 | 246 | staticvoidusage(constchar*); |
@@ -1543,48 +1544,34 @@ reaper(SIGNAL_ARGS) |
1543 | 1544 | */ |
1544 | 1545 | if (pgstat_ispgstat(pid)) |
1545 | 1546 | { |
1546 | | -if (WIFEXITED(exitstatus)) |
1547 | | -elog(DEBUG,"statistics collector exited with status %d", |
1548 | | -WEXITSTATUS(exitstatus)); |
1549 | | -elseif (WIFSIGNALED(exitstatus)) |
1550 | | -elog(DEBUG,"statistics collector was terminated by signal %d", |
1551 | | -WTERMSIG(exitstatus)); |
| 1547 | +elog(DEBUG,"statistics collector process (pid %d) %s", |
| 1548 | +pid,formatExitStatus(exitstatus)); |
1552 | 1549 | pgstat_start(); |
1553 | 1550 | continue; |
1554 | 1551 | } |
1555 | 1552 |
|
| 1553 | +/* |
| 1554 | + * Check if this child was a shutdown or startup process. |
| 1555 | + */ |
1556 | 1556 | if (ShutdownPID>0&&pid==ShutdownPID) |
1557 | 1557 | { |
1558 | | -if (WIFEXITED(exitstatus)&&WEXITSTATUS(exitstatus)!=0) |
1559 | | -{ |
1560 | | -elog(DEBUG,"shutdown process %d exited with status %d", |
1561 | | -pid,WEXITSTATUS(exitstatus)); |
1562 | | -ExitPostmaster(1); |
1563 | | -} |
1564 | | -if (WIFSIGNALED(exitstatus)) |
| 1558 | +if (exitstatus!=0) |
1565 | 1559 | { |
1566 | | -elog(DEBUG,"shutdown process%d was terminated by signal %d", |
1567 | | -pid,WTERMSIG(exitstatus)); |
| 1560 | +elog(DEBUG,"shutdown process(pid %d) %s", |
| 1561 | +pid,formatExitStatus(exitstatus)); |
1568 | 1562 | ExitPostmaster(1); |
1569 | 1563 | } |
1570 | 1564 | ExitPostmaster(0); |
1571 | 1565 | } |
1572 | 1566 |
|
1573 | 1567 | if (StartupPID>0&&pid==StartupPID) |
1574 | 1568 | { |
1575 | | -if (WIFEXITED(exitstatus)&&WEXITSTATUS(exitstatus)!=0) |
| 1569 | +if (exitstatus!=0) |
1576 | 1570 | { |
1577 | | -elog(DEBUG,"startup process%d exited with status %d; aborting startup", |
1578 | | -pid,WEXITSTATUS(exitstatus)); |
| 1571 | +elog(DEBUG,"startup process(pid %d) %s; aborting startup", |
| 1572 | +pid,formatExitStatus(exitstatus)); |
1579 | 1573 | ExitPostmaster(1); |
1580 | 1574 | } |
1581 | | -if (WIFSIGNALED(exitstatus)) |
1582 | | -{ |
1583 | | -elog(DEBUG,"shutdown process %d was terminated by signal %d; aborting startup", |
1584 | | -pid,WTERMSIG(exitstatus)); |
1585 | | -ExitPostmaster(1); |
1586 | | -} |
1587 | | - |
1588 | 1575 | StartupPID=0; |
1589 | 1576 | FatalError= false;/* done with recovery */ |
1590 | 1577 | if (Shutdown>NoShutdown) |
@@ -1664,8 +1651,8 @@ CleanupProc(int pid, |
1664 | 1651 | Backend*bp; |
1665 | 1652 |
|
1666 | 1653 | if (DebugLvl) |
1667 | | -elog(DEBUG,"CleanupProc: pid %d exited with status %d", |
1668 | | -pid,exitstatus); |
| 1654 | +elog(DEBUG,"CleanupProc:child process (pid %d) %s", |
| 1655 | +pid,formatExitStatus(exitstatus)); |
1669 | 1656 |
|
1670 | 1657 | /* |
1671 | 1658 | * If a backend dies in an ugly way (i.e. exit status not 0) then we |
@@ -1710,12 +1697,8 @@ CleanupProc(int pid, |
1710 | 1697 | /* Make log entry unless we did so already */ |
1711 | 1698 | if (!FatalError) |
1712 | 1699 | { |
1713 | | -if (WIFEXITED(exitstatus)) |
1714 | | -elog(DEBUG,"server process (pid %d) exited with status %d", |
1715 | | -pid,WEXITSTATUS(exitstatus)); |
1716 | | -elseif (WIFSIGNALED(exitstatus)) |
1717 | | -elog(DEBUG,"server process (pid %d) was terminated by signal %d", |
1718 | | -pid,WTERMSIG(exitstatus)); |
| 1700 | +elog(DEBUG,"server process (pid %d) %s", |
| 1701 | +pid,formatExitStatus(exitstatus)); |
1719 | 1702 | elog(DEBUG,"terminating any other active server processes"); |
1720 | 1703 | } |
1721 | 1704 |
|
@@ -1772,6 +1755,36 @@ CleanupProc(int pid, |
1772 | 1755 | FatalError= true; |
1773 | 1756 | } |
1774 | 1757 |
|
| 1758 | +/* |
| 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. |
| 1762 | + */ |
| 1763 | +staticconstchar* |
| 1764 | +formatExitStatus(intexitstatus) |
| 1765 | +{ |
| 1766 | +staticcharresult[100]; |
| 1767 | + |
| 1768 | +/* |
| 1769 | + * translator: these strings provide the verb phrase in the preceding |
| 1770 | + * messages such as "server process (pid %d) %s" |
| 1771 | + */ |
| 1772 | +if (WIFEXITED(exitstatus)) |
| 1773 | +snprintf(result,sizeof(result), |
| 1774 | +gettext("exited with exit code %d"), |
| 1775 | +WEXITSTATUS(exitstatus)); |
| 1776 | +elseif (WIFSIGNALED(exitstatus)) |
| 1777 | +snprintf(result,sizeof(result), |
| 1778 | +gettext("was terminated by signal %d"), |
| 1779 | +WTERMSIG(exitstatus)); |
| 1780 | +else |
| 1781 | +snprintf(result,sizeof(result), |
| 1782 | +gettext("exited with unexpected status %d"), |
| 1783 | +exitstatus); |
| 1784 | + |
| 1785 | +returnresult; |
| 1786 | +} |
| 1787 | + |
1775 | 1788 | /* |
1776 | 1789 | * Send a signal to all backend children. |
1777 | 1790 | */ |
|