*
*
* 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
*
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 *);
*/
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;
}
{
if (exitstatus != 0)
{
- elog(DEBUG, "shutdown process (pid %d) %s",
- pid, formatExitStatus(exitstatus));
+ LogChildExit(gettext("shutdown process"),
+ pid, exitstatus);
ExitPostmaster(1);
}
ExitPostmaster(0);
{
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;
* 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,
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
/* 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");
}
}
/*
- * 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);
}
/*