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
select.c
Description: select.c
win32_signals_3.patch
Description: win32_signals_3.patch
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org