Re: [HACKERS] Win32 WEXITSTATUS too

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Chuck McDevitt <cmcdevitt(at)greenplum(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Takayuki Tsunakawa <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Subject: Re: [HACKERS] Win32 WEXITSTATUS too
Date: 2007-01-25 22:10:13
Message-ID: 200701252210.l0PMAEn28223@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Chuck McDevitt wrote:
> Win32 exception codes start with a two-bit severity indication.
> 00 means "success", so nothing is wrong.
> 01 is an "informational" messages.
> 10 is a "warning" message.
> 11 is an "error".
>
> That's why the common exception codes you see start with hex C0, as they
> are "errors".
>
> The rest of the top 16 bits are the "facility" that caused the error.
> Often not filled in.
>
> To Convert an NT exception code (ntstatus) to a Win32 error code, you
> call this routine:
>
> ULONG RtlNtStatusToDosError(
> NTSTATUS Status
> );
>
>
> Then you can pass it to FormatMessage and it will work.

I looked on MinGW and it seems it doesn't support
RtlNtStatusToDosError(), so I just added a comment that some day we
might want to use it:

* Some day we might want to print descriptions for the most common
* exceptions, rather than printing an include file name. We could use
* RtlNtStatusToDosError() and pass to FormatMessage(), which can print
* the text of error values, but MinGW does not support
* RtlNtStatusToDosError().

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

>
>
> -----Original Message-----
> From: pgsql-patches-owner(at)postgresql(dot)org
> [mailto:pgsql-patches-owner(at)postgresql(dot)org] On Behalf Of Bruce Momjian
> Sent: Tuesday, January 23, 2007 7:35 AM
> To: Tom Lane
> Cc: Magnus Hagander; Takayuki Tsunakawa; PostgreSQL-patches; Alvaro
> Herrera; ITAGAKI Takahiro
> Subject: Re: [pgsql-patches] [HACKERS] Win32 WEXITSTATUS too
>
> Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > Magnus Hagander wrote:
> > >> Now, if we're only caring about exit() from *postgresqls own
> processes*,
> > >> that might hold true. In which case I withdraw that objection as
> long as
> > >> the comment i updated to reflect this ;-) But if we're talking
> about
> > >> exit() in general of any process, then it's simply wrong.
> >
> > > Right, that code is only used by the backend and tools.
> >
> > We can reasonably assume that no Postgres code will exit() with a
> value
> > bigger than 255, because to do so would be unportable.
> >
> > I'm more concerned about the other direction: can we be sure that a
> > status value less than 255 is from exit() rather than something that
> > should be called an exception?
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-01-25 22:28:32 Re: [GENERAL] Autovacuum Improvements
Previous Message Andrew Dunstan 2007-01-25 21:37:21 Re: BUG #2917: spi_prepare doesn't accept typename aliases

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2007-01-25 23:01:58 Re: uuid patch 2.0 (8.3devel)
Previous Message Gevik Babakhani 2007-01-25 21:47:19 uuid patch 2.0 (8.3devel)