Re: Bug in signal handler [Was: [TODO] Allow commenting

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Zdenek Kotala <zdenek(dot)kotala(at)sun(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Bug in signal handler [Was: [TODO] Allow commenting
Date: 2006-05-11 12:17:44
Message-ID: 20060511121744.GF30113@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 11, 2006 at 01:59:46PM +0200, Zdenek Kotala wrote:
> Decision is that Postgres uses signal dangerous functions (fopen, ...)
> and its signal handler is not save and should generate unpredictable
> behavior after signal processing. I would like to fix it, but there is
> some waiting patches for this source and I don't know how to correctly
> (with minimal merge complication) process.

Look at the code more carefully. The restriction is that it is unsafe
to call non-reentrant functions from within a signal handler while
there may be a non-reentrant function run by the main program.

If you look at the code in postmaster.c, the only place the signal
handler can run is between the block (line 1223) and unblock (line
1231), the only function there is select() which is specifically listed
as being safe.

Running unsafe functions within a signal handler is not unsafe per-se.
It's only unsafe if the main program could also be running unsafe
functions.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Douglas McNaught 2006-05-11 12:24:02 Re: Bug in signal handler
Previous Message Zdenek Kotala 2006-05-11 11:59:46 Re: Bug in signal handler [Was: [TODO] Allow commenting