Commit 882b9948 authored by Bruce Momjian's avatar Bruce Momjian

Back out use of FormatMessage(), does error values, not exception

values.  Point to /include/ntstatus.h for an exception list, rather than
a URL.
parent 610f60a0
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.511 2007/01/23 01:45:11 momjian Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.512 2007/01/23 03:28:49 momjian Exp $
* *
* NOTES * NOTES
* *
...@@ -2430,30 +2430,14 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus) ...@@ -2430,30 +2430,14 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
(errmsg("%s (PID %d) was terminated by signal %d", (errmsg("%s (PID %d) was terminated by signal %d",
procname, pid, WTERMSIG(exitstatus)))); procname, pid, WTERMSIG(exitstatus))));
#else #else
{
static char last_system_error[512];
if (WERRORCODE(exitstatus) == 0 ||
FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
WERRORCODE(exitstatus),
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
last_system_error,
sizeof(last_system_error) - 1,
NULL) == 0)
snprintf(last_system_error, sizeof(last_system_error) - 1,
"Unknown error %X.", WEXITSTATUS(exitstatus));
ereport(lev, ereport(lev,
/*------ /*------
translator: %s is a noun phrase describing a child process, such as translator: %s is a noun phrase describing a child process, such as
"server process" */ "server process" */
(errmsg("%s (PID %d) was terminated by the operating system", (errmsg("%s (PID %d) was terminated by exception %X",
procname, pid), procname, pid, WTERMSIG(exitstatus)),
errdetail("%s", last_system_error))); errhint("See /include/ntstatus.h for a description of the hex value.")));
}
#endif #endif
else else
ereport(lev, ereport(lev,
......
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.68 2007/01/23 01:45:11 momjian Exp $ */ /* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.69 2007/01/23 03:28:49 momjian Exp $ */
#if defined(_MSC_VER) || defined(__BORLANDC__) #if defined(_MSC_VER) || defined(__BORLANDC__)
#define WIN32_ONLY_COMPILER #define WIN32_ONLY_COMPILER
...@@ -140,26 +140,14 @@ int semop(int semId, struct sembuf * sops, int flag); ...@@ -140,26 +140,14 @@ int semop(int semId, struct sembuf * sops, int flag);
* Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt * Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt
* MS SDK - http://www.nologs.com/ntstatus.html * MS SDK - http://www.nologs.com/ntstatus.html
* *
* Because FormatMessage only handles NT_ERROR strings, and assumes they * Some day we might want to print descriptions for the most common
* do not have the 0xC prefix, we strip it to match this list: * exceptions, rather than printing a URL. FormatMessage() can print
* http://msdn2.microsoft.com/en-us/library/ms681381.aspx * the text of error values, but not exception values.
*
* When using FormatMessage():
*
* On MinGW, system() returns STATUS_* values. MSVC might be
* different. To test, create a binary that does *(NULL), and
* then create a second binary that calls it via system(),
* and check the return value of system(). On MinGW, it is
* 0xC0000005 == STATUS_ACCESS_VIOLATION, and 0x5 is a value
* FormatMessage() can look up. GetLastError() does not work;
* always zero.
*/ */
#define STATUS_ERROR_MASK 0xC0000000 #define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0)
#define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0) #define WIFSIGNALED(w) (!WIFEXITED(w))
#define WIFSIGNALED(w) (!WIFEXITED(w)) #define WEXITSTATUS(w) (w)
#define WEXITSTATUS(w) (w) #define WTERMSIG(w) (w)
#define WERRORCODE(w) ((((w) & STATUS_ERROR_MASK) == STATUS_ERROR_MASK) ? \
((w) & ~STATUS_ERROR_MASK) : 0)
#define sigmask(sig) ( 1 << ((sig)-1) ) #define sigmask(sig) ( 1 << ((sig)-1) )
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/exec.c,v 1.46 2007/01/23 01:45:11 momjian Exp $ * $PostgreSQL: pgsql/src/port/exec.c,v 1.47 2007/01/23 03:28:49 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -586,24 +586,8 @@ pclose_check(FILE *stream) ...@@ -586,24 +586,8 @@ pclose_check(FILE *stream)
log_error(_("child process was terminated by signal %d"), log_error(_("child process was terminated by signal %d"),
WTERMSIG(exitstatus)); WTERMSIG(exitstatus));
#else #else
{ log_error(_("child process was terminated by exception %X\nSee /include/ntstatus.h for a description\nof the hex value."),
static char last_system_error[512]; WTERMSIG(exitstatus));
if (WERRORCODE(exitstatus) == 0 ||
FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
WERRORCODE(exitstatus),
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
last_system_error,
sizeof(last_system_error) - 1,
NULL) == 0)
snprintf(last_system_error, sizeof(last_system_error) - 1,
"Unknown error %X.", WEXITSTATUS(exitstatus));
log_error(_("child process was terminated by the operating system\n%s"),
last_system_error);
}
#endif #endif
else else
log_error(_("child process exited with unrecognized status %d"), log_error(_("child process exited with unrecognized status %d"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment