Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd22e945

Browse files
committed
Clean up formatting of child process exit-status reports so that they
are correct, consistent, and complete ... motivated by gripe fromOliver Elphick, but I see someone had already made an incomplete stabat this.
1 parentd2ff7e5 commitd22e945

File tree

1 file changed

+47
-34
lines changed

1 file changed

+47
-34
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 47 additions & 34 deletions
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.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 $
4141
*
4242
* NOTES
4343
*
@@ -240,6 +240,7 @@ static void reaper(SIGNAL_ARGS);
240240
staticvoidsigusr1_handler(SIGNAL_ARGS);
241241
staticvoiddummy_handler(SIGNAL_ARGS);
242242
staticvoidCleanupProc(intpid,intexitstatus);
243+
staticconstchar*formatExitStatus(intexitstatus);
243244
staticintDoBackend(Port*port);
244245
staticvoidExitPostmaster(intstatus);
245246
staticvoidusage(constchar*);
@@ -1543,48 +1544,34 @@ reaper(SIGNAL_ARGS)
15431544
*/
15441545
if (pgstat_ispgstat(pid))
15451546
{
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));
15521549
pgstat_start();
15531550
continue;
15541551
}
15551552

1553+
/*
1554+
* Check if this child was a shutdown or startup process.
1555+
*/
15561556
if (ShutdownPID>0&&pid==ShutdownPID)
15571557
{
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)
15651559
{
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));
15681562
ExitPostmaster(1);
15691563
}
15701564
ExitPostmaster(0);
15711565
}
15721566

15731567
if (StartupPID>0&&pid==StartupPID)
15741568
{
1575-
if (WIFEXITED(exitstatus)&&WEXITSTATUS(exitstatus)!=0)
1569+
if (exitstatus!=0)
15761570
{
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));
15791573
ExitPostmaster(1);
15801574
}
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-
15881575
StartupPID=0;
15891576
FatalError= false;/* done with recovery */
15901577
if (Shutdown>NoShutdown)
@@ -1664,8 +1651,8 @@ CleanupProc(int pid,
16641651
Backend*bp;
16651652

16661653
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));
16691656

16701657
/*
16711658
* If a backend dies in an ugly way (i.e. exit status not 0) then we
@@ -1710,12 +1697,8 @@ CleanupProc(int pid,
17101697
/* Make log entry unless we did so already */
17111698
if (!FatalError)
17121699
{
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));
17191702
elog(DEBUG,"terminating any other active server processes");
17201703
}
17211704

@@ -1772,6 +1755,36 @@ CleanupProc(int pid,
17721755
FatalError= true;
17731756
}
17741757

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+
17751788
/*
17761789
* Send a signal to all backend children.
17771790
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp