Skip site navigation (1) Skip section navigation (2)

Re: signals on windows

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: signals on windows
Date: 2003-10-10 03:31:45
Message-ID: 200310100331.h9A3VjL08161@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers-win32
Andrew Dunstan wrote:
> 
> here's what I was going to put into initdb.c for signal handling - 
> comments welcome - as I think about it more I'm strongly leaning to the 
> "set a flag" solution - we'd check for the flag before outputting "ok" 
> in various places.

I assume we will have some sort of signals in Win32, though their
delivery will be probably via shared memory flags, so that might not
work for initdb.  The flag solution may be best for initdb.

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


> 
> cheers
> 
> andrew
> 
> /*
>  * signal handler in case we are interrupted.
>  *
>  * The Windows runtime docs at
>  * http://msdn.microsoft.com/library/en-us/vclib/html/_crt_signal.asp
>  * specifically forbid a number of things being done from a signal handler,
>  * most of which we do :-) (specifically, we do IO, mem allocation and 
> system
>  * calls). Also note the behaviour of Windows with SIGINT, which says this:
>  *   Note   SIGINT is not supported for any Win32 application, including
>  *   Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs,
>  *   Win32 operating systems generate a new thread to specifically handle
>  *   that interrupt. This can cause a single-thread application such as 
> UNIX,
>  *   to become multithreaded, resulting in unexpected behavior.
>  * I have no idea how to handle this. (Strange they call UNIX an 
> application!)
>  * So this will need some testing on Windows.
>  * One alternative might be to set a flag that we periodically check for.
>  *
>  */
> 
> static void
> trapsig(int signum)
> {
>   fputs("Caught Signal.\n",stderr);
>   exit_nicely();
> }
> 
> [snip]
> 
> #ifdef SIGHUP  
>     pqsignal(SIGHUP,trapsig);
> #endif
> #ifdef SIGINT
>     pgsignal(SIGINT,trapsig);
> #endif
> #ifdef SIGQUIT
>     pgsignal(SIGQUIT,trapsig);
> #endif
> #ifdef SIGTERM
>     pgsignal(SIGTERM,trapsig);
> #endif
>    
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers-win32 by date

Next:From: Marsh RayDate: 2003-10-10 04:09:40
Subject: Re: signals on windows
Previous:From: Bruce MomjianDate: 2003-10-10 03:29:32
Subject: Re: lib problems

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group