diff options
author | Bruce Momjian | 2007-01-23 01:45:11 +0000 |
---|---|---|
committer | Bruce Momjian | 2007-01-23 01:45:11 +0000 |
commit | 610f60a092ea178b96baebd7d4ee958c8061606e (patch) | |
tree | 8bdce5e522a9c9555a2f40e96bc06cd1b2608003 /src/port/exec.c | |
parent | b97b86649a1acdf078d7630e7a2407ac11edea66 (diff) |
Print meaningfull error text for abonormal process exit on Win32, rather
than hex codes, using FormatMessage().
Diffstat (limited to 'src/port/exec.c')
-rw-r--r-- | src/port/exec.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/port/exec.c b/src/port/exec.c index 4d54ed0e589..0ed4b59014b 100644 --- a/src/port/exec.c +++ b/src/port/exec.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/exec.c,v 1.45 2007/01/22 18:31:51 momjian Exp $ + * $PostgreSQL: pgsql/src/port/exec.c,v 1.46 2007/01/23 01:45:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -586,8 +586,24 @@ pclose_check(FILE *stream) log_error(_("child process was terminated by signal %d"), WTERMSIG(exitstatus)); #else - log_error(_("child process was terminated by exception %X\nSee http://source.winehq.org/source/include/ntstatus.h for a description\nof the hex value."), - WTERMSIG(exitstatus)); + { + 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)); + + log_error(_("child process was terminated by the operating system\n%s"), + last_system_error); + } #endif else log_error(_("child process exited with unrecognized status %d"), |