From: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
---|---|
To: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [GENERAL] division by zero |
Date: | 2003-03-10 19:37:35 |
Message-ID: | 303E00EBDD07B943924382E153890E5433F7F0@cuthbert.rcsinc.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> The big question is how to fix this on Win32. Is a test in the
integer
> division routines enough? Is there a signal to catch on Win32?
After fighting with the docs a little bit, here is how to handle an
int/0 in a C application.
#include "stdio.h"
#include "excpt.h"
#include "windows.h"
int HandleException( int iExcept );
int main(int argc, char* argv[])
{
int b = 0;
int a;
puts("hello");
__try
{
puts("in try");
a = 0/b;
}
__except( HandleException(GetExceptionCode()) )
{
puts("in except");
}
puts("world");
}
int HandleException( int iExcept )
{
if (iExcept == EXCEPTION_INT_DIVIDE_BY_ZERO)
{
puts("Handled int/0 exception");
return EXCEPTION_EXECUTE_HANDLER;
}
/* call the system handler and crash */
return EXCEPTION_CONTINUE_SEARCH ;
}
Merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Rod Taylor | 2003-03-10 19:41:36 | Re: Roadmap for FE/BE protocol redesign |
Previous Message | Tom Lane | 2003-03-10 19:30:22 | Re: Roadmap for FE/BE protocol redesign |