OK, I have tested on MinGW and found I can use FormatMessage() to print
a description for all ERROR* system() failures, rather than print a hex
value.  This removes the need for a URL or lookup of hex values. 
Attached and applied.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> bruce wrote:
> > Tom Lane wrote:
> > > Alvaro Herrera <[EMAIL PROTECTED]> writes:
> > > > Bruce Momjian wrote:
> > > >> OK, maybe /doc or src/tools.  A more radical approach would be to put
> > > >> the list in our documentation, or have initdb install it.
> > > 
> > > > Why not put it in techdocs or some such?
> > > 
> > > I think we've learned by now that putting copies of other peoples' code
> > > in our tree isn't such a hot idea; what is going to cause it to be
> > > updated when things change?  How do you know the values are even the
> > > same across all the Windows versions we support?
> > > 
> > > Basically this whole idea is misconceived.  Just print the number and
> > > have done.
> > 
> > And how do people interpret that number?
> 
> Ah, I found something:
> 
>       http://support.microsoft.com/kb/259693
> 
> Someone on IRC says that is kernel mode only, and is looking for a
> user-mode version, so we would be able to print out a meaningful message
> rather than a hex value that has to be looked up.
> 
> -- 
>   Bruce Momjian   [EMAIL PROTECTED]
>   EnterpriseDB    http://www.enterprisedb.com
> 
>   + If your life is a hard drive, Christ can be your backup. +
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.510
diff -c -c -r1.510 postmaster.c
*** src/backend/postmaster/postmaster.c	22 Jan 2007 19:38:05 -0000	1.510
--- src/backend/postmaster/postmaster.c	23 Jan 2007 01:43:22 -0000
***************
*** 2430,2443 ****
  				(errmsg("%s (PID %d) was terminated by signal %d",
  						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",
! 						procname, pid, WTERMSIG(exitstatus)),
! 				 errhint("See http://source.winehq.org/source/include/ntstatus.h for a description of the hex value.")));
  #endif
  	else
  		ereport(lev,
--- 2430,2459 ----
  				(errmsg("%s (PID %d) was terminated by signal %d",
  						procname, pid, WTERMSIG(exitstatus))));
  #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,
+ 	
  		/*------
  		  translator: %s is a noun phrase describing a child process, such as
  		  "server process" */
! 				(errmsg("%s (PID %d) was terminated by the operating system",
! 						procname, pid),
! 				 errdetail("%s", last_system_error)));
! 	}
  #endif
  	else
  		ereport(lev,
Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port/win32.h,v
retrieving revision 1.67
diff -c -c -r1.67 win32.h
*** src/include/port/win32.h	22 Jan 2007 18:32:57 -0000	1.67
--- src/include/port/win32.h	23 Jan 2007 01:43:23 -0000
***************
*** 140,152 ****
   *		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 WIFEXITED(w)    (((w) & 0XFFFFFF00) == 0)
! #define WIFSIGNALED(w)  (!WIFEXITED(w))
! #define WEXITSTATUS(w)  (w)
! #define WTERMSIG(w)     (w)
  
  #define sigmask(sig) ( 1 << ((sig)-1) )
  
--- 140,165 ----
   *		Descriptions - http://www.comp.nus.edu.sg/~wuyongzh/my_doc/ntstatus.txt
   *		MS SDK - http://www.nologs.com/ntstatus.html
   *
!  *	Because FormatMessage only handles NT_ERROR strings, and assumes they
!  *	do not have the 0xC prefix, we strip it to match this list:
!  *		http://msdn2.microsoft.com/en-us/library/ms681381.aspx
!  *
!  *	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 WIFSIGNALED(w)		(!WIFEXITED(w))
! #define WEXITSTATUS(w)		(w)
! #define WERRORCODE(w)		((((w) & STATUS_ERROR_MASK) == STATUS_ERROR_MASK) ? \
! 							((w) & ~STATUS_ERROR_MASK) : 0)
  
  #define sigmask(sig) ( 1 << ((sig)-1) )
  
Index: src/port/exec.c
===================================================================
RCS file: /cvsroot/pgsql/src/port/exec.c,v
retrieving revision 1.45
diff -c -c -r1.45 exec.c
*** src/port/exec.c	22 Jan 2007 18:31:51 -0000	1.45
--- src/port/exec.c	23 Jan 2007 01:43:24 -0000
***************
*** 586,593 ****
  		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));
  #endif
  	else
  		log_error(_("child process exited with unrecognized status %d"),
--- 586,609 ----
  		log_error(_("child process was terminated by signal %d"),
  				  WTERMSIG(exitstatus));
  #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));
! 
! 		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"),
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to