Re: What (not) to do in signal handlers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What (not) to do in signal handlers
Date: 2001-06-14 18:18:40
Message-ID: 18682.992542720@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> I notice that the signal handlers in postmaster.c do quite a lot of work,
> much more than what they teach you in school they should do.

Yes, they're pretty ugly. However, we have not recently heard any
complaints suggesting problems with it. Since we block signals
everywhere except just around the select() for new input, there's not
really any risk of recursive resource use AFAICS.

> ISTM that most of these, esp. pmdie(), can be written more like the SIGHUP
> handler, i.e., set a global variable and evaluate right after the
> select().

I would love to see it done that way, *if* you can show me a way to
guarantee that the signal response will happen promptly. AFAIK there's
no portable way to ensure that we don't end up sitting and waiting for a
new client message before we get past the select(). If we could release
the signal mask just as an atomic part of the select operation, then
it'd work, but only some platforms support that. This has been
discussed before, look in the archives.

SIGHUP is okay because we don't really care whether the postmaster
rereads the config file right away or only when it's about to process a
new request, anyhow. But for other sorts of signals we need to be sure
that there can't be an indefinite delay before the signal is acted on.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-06-14 19:46:41 Re: Removal of temp tables
Previous Message Bruce Momjian 2001-06-14 18:18:29 Re: Removal of temp tables