mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
When system() fails in Win32, report it as an exception, print the
exception value in hex, and give a URL where the value can be looked-up.
This commit is contained in:
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.508 2007/01/16 13:28:56 alvherre Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.509 2007/01/22 18:31:51 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -2421,6 +2421,7 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
|
|||||||
(errmsg("%s (PID %d) exited with exit code %d",
|
(errmsg("%s (PID %d) exited with exit code %d",
|
||||||
procname, pid, WEXITSTATUS(exitstatus))));
|
procname, pid, WEXITSTATUS(exitstatus))));
|
||||||
else if (WIFSIGNALED(exitstatus))
|
else if (WIFSIGNALED(exitstatus))
|
||||||
|
#ifndef WIN32
|
||||||
ereport(lev,
|
ereport(lev,
|
||||||
|
|
||||||
/*------
|
/*------
|
||||||
@ -2428,6 +2429,15 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
|
|||||||
"server process" */
|
"server process" */
|
||||||
(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
|
||||||
|
ereport(lev,
|
||||||
|
|
||||||
|
/*------
|
||||||
|
translator: %s is a noun phrase describing a child process, such as
|
||||||
|
"server process" */
|
||||||
|
(errmsg("%s (PID %d) was terminated by exception %X\nSee http://source.winehq.org/source/include/ntstatus.h for a description\nof the hex value.",
|
||||||
|
procname, pid, WTERMSIG(exitstatus))));
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
ereport(lev,
|
ereport(lev,
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.65 2007/01/11 02:42:31 momjian Exp $ */
|
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.66 2007/01/22 18:31:51 momjian Exp $ */
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
#define WIN32_ONLY_COMPILER
|
#define WIN32_ONLY_COMPILER
|
||||||
@ -115,16 +115,38 @@ int semop(int semId, struct sembuf * sops, int flag);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Signal stuff
|
* Signal stuff
|
||||||
* WIN32 doesn't have wait(), so the return value for children
|
*
|
||||||
* is simply the return value specified by the child, without
|
* For WIN32, there is no wait() call so there are no wait() macros
|
||||||
* any additional information on whether the child terminated
|
* to interpret the return value of system(). Instead, system()
|
||||||
* on its own or via a signal. These macros are also used
|
* return values < 0x100 are used for exit() termination, and higher
|
||||||
* to interpret the return value of system().
|
* values are used to indicated non-exit() termination, which is
|
||||||
|
* similar to a unix-style signal exit (think SIGSEGV ==
|
||||||
|
* STATUS_ACCESS_VIOLATION). Return values are broken up into groups:
|
||||||
|
*
|
||||||
|
* http://msdn2.microsoft.com/en-gb/library/aa489609.aspx
|
||||||
|
*
|
||||||
|
* NT_SUCCESS 0 - 0x3FFFFFFF
|
||||||
|
* NT_INFORMATION 0x40000000 - 0x7FFFFFFF
|
||||||
|
* NT_WARNING 0x80000000 - 0xBFFFFFFF
|
||||||
|
* NT_ERROR 0xC0000000 - 0xFFFFFFFF
|
||||||
|
*
|
||||||
|
* Effectively, we don't care on the severity of the return value from
|
||||||
|
* system(), we just need to know if it was because of exit() or generated
|
||||||
|
* by the system, and it seems values >= 0x100 are system-generated.
|
||||||
|
* See this URL for a list of WIN32 STATUS_* values:
|
||||||
|
*
|
||||||
|
* Wine (URL used in our error messages) -
|
||||||
|
* http://source.winehq.org/source/include/ntstatus.h
|
||||||
|
* Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt
|
||||||
|
* MS SDK - http://www.nologs.com/ntstatus.html
|
||||||
|
*
|
||||||
|
* Some day we might want to print descriptions for the most common
|
||||||
|
* exceptions, rather than printing a URL.
|
||||||
*/
|
*/
|
||||||
#define WEXITSTATUS(w) (w)
|
#define WIFEXITED(w) (((w) & 0xffffff00) == 0)
|
||||||
#define WIFEXITED(w) (true)
|
#define WIFSIGNALED(w) (!WIFEXITED(w))
|
||||||
#define WIFSIGNALED(w) (false)
|
#define WEXITSTATUS(w) (w)
|
||||||
#define WTERMSIG(w) (0)
|
#define WTERMSIG(w) (w)
|
||||||
|
|
||||||
#define sigmask(sig) ( 1 << ((sig)-1) )
|
#define sigmask(sig) ( 1 << ((sig)-1) )
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/port/exec.c,v 1.44 2007/01/05 22:20:02 momjian Exp $
|
* $PostgreSQL: pgsql/src/port/exec.c,v 1.45 2007/01/22 18:31:51 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -582,8 +582,13 @@ pclose_check(FILE *stream)
|
|||||||
log_error(_("child process exited with exit code %d"),
|
log_error(_("child process exited with exit code %d"),
|
||||||
WEXITSTATUS(exitstatus));
|
WEXITSTATUS(exitstatus));
|
||||||
else if (WIFSIGNALED(exitstatus))
|
else if (WIFSIGNALED(exitstatus))
|
||||||
|
#ifndef WIN32
|
||||||
log_error(_("child process was terminated by signal %d"),
|
log_error(_("child process was terminated by signal %d"),
|
||||||
WTERMSIG(exitstatus));
|
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));
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
log_error(_("child process exited with unrecognized status %d"),
|
log_error(_("child process exited with unrecognized status %d"),
|
||||||
exitstatus);
|
exitstatus);
|
||||||
|
Reference in New Issue
Block a user