New win32 signals patch (3)

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "pgsql-hackers-win32" <pgsql-hackers-win32(at)postgresql(dot)org>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: New win32 signals patch (3)
Date: 2004-02-03 23:46:02
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE34B0FA@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-patches

Ok, time for yet another signals patch :-)

This one replaces the one I posted yesterday - I managed to mess up my
build environment pretty bad, so while that patch worked in that one, it
would not work on a clean system. There was also a clean bug in pqselect
with regards to NULL timeouts.

As before, also adds backend/port/win32/select.c

ATM, for review, not for applying.

Anyway, step-by-step what's in the patch:
1) Per discussion with Bruce, reverts the change from kill() to pqkill()
on all platforms. Instead, #define away kill() to pqkill() in
port/win32.h, and just use kill() directly on unix platforms. Similar
changes for pqsigsetmask, except they are all local to pqsignal.h.

2) Implements pqselect() in similar ways. This function appears just as
select() to the user. Internally, it runs a loop where it polls for
signals once / second. This allows the backend to actually shut down,
since we can deliver signals to both postmaster and statistics
processes. Ordinary backends cannot yet be shut down, since they don't
use select, but a blocking recv() instead. I'll get to those soon...

3) Remove duplicate signal definitions. Signal numbers were defined in
both win32.h and pqsignal.h.

4) Adds a Console Control Handler to signals handling. This one will
pick up Ctrl-C, Ctrl-Break, Window close and System shutdown, and
translate them into a SIGINT signal. NOTE! This handler does not work if
the postmaster is started from a msys console, just if it's run from the
windows command prompt.

5) Adds a thread to the postmaster only that looks for child processes
that exit, and sends SIGCHLD to the postmaster. This is the only part of
the server that actually uses it, so no need to put it in the other
processes.

6) Fixes a typo in one of Claudios patches on a cast. Has no effect on
functionality, but causes an unnecessary warning.

With this patch, we get the following:
a) No need for that hack around StartupPID to get it to start
b) It's possible to shut the server down, in smart, fast and immidiate
mode.

The only hack required to get a working (as in can hit simple queries
against the system tables at least) backend is the errno checks in
slru.c

//Magnus

Attachment Content-Type Size
select.c application/octet-stream 1.7 KB
win32_signals_3.patch application/octet-stream 20.8 KB

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Claudio Natoli 2004-02-04 03:32:50 Re: New win32 signals patch (3)
Previous Message Merlin Moncure 2004-02-03 20:32:43 interix port running...

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-02-04 00:50:51 Re: [PATCHES] log session end - again
Previous Message Tom Lane 2004-02-03 23:09:26 Re: [PATCHES] log session end - again