Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e2a203a

Browse files
committed
initdb needs pqsignal() even on Windows.
I had thought we weren't using this version of pqsignal() at all on Windows, but that's wrong --- initdb is using it (and coping with the POSIX-ish semantics of bare signal() :-(). So allow the file to be built in WIN32+FRONTEND case, and add it to the MSVC build logic.
1 parent 8c41cb6 commit e2a203a

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/include/port.h

-3
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,8 @@ extern int pg_check_dir(const char *dir);
463463
extern int pg_mkdir_p(char *path, int omode);
464464

465465
/* port/pqsignal.c */
466-
/* On Windows, we can emulate pqsignal in the backend, but not frontend */
467-
#if !defined(WIN32) || !defined(FRONTEND)
468466
typedef void (*pqsigfunc) (int signo);
469467
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
470-
#endif
471468

472469
/* port/quotes.c */
473470
extern char *escape_single_quotes_ascii(const char *src);

src/port/pqsignal.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@
2929
* neither POSIX signals nor BSD signals. The alternative is to do
3030
* signal-handler reinstallation, which doesn't work well at all.
3131
*
32-
* Windows, of course, is resolutely in a class by itself. This file
33-
* should not get compiled at all on Windows. We have an emulation of
34-
* pqsignal() in src/backend/port/win32/signal.c for the backend
35-
* environment; frontend programs are out of luck.
32+
* Windows, of course, is resolutely in a class by itself. In the backend,
33+
* we don't use this file at all; src/backend/port/win32/signal.c provides
34+
* pqsignal() for the backend environment. Frontend programs can use
35+
* this version of pqsignal() if they wish, but beware that Windows
36+
* requires signal-handler reinstallation, because indeed it provides
37+
* neither POSIX signals nor BSD signals :-(
3638
* ------------------------------------------------------------------------
3739
*/
3840

3941
#include "c.h"
4042

4143
#include <signal.h>
4244

43-
#ifndef WIN32
45+
#if !defined(WIN32) || defined(FRONTEND)
4446

4547
/*
4648
* Set up a signal handler for signal "signo"
4749
*
48-
* Returns the previous handler. It's expected that the installed handler
49-
* will persist across multiple deliveries of the signal (unlike the original
50-
* POSIX definition of signal(2)).
50+
* Returns the previous handler.
5151
*/
5252
pqsigfunc
5353
pqsignal(int signo, pqsigfunc func)
@@ -73,4 +73,4 @@ pqsignal(int signo, pqsigfunc func)
7373
#endif /* !HAVE_POSIX_SIGNALS */
7474
}
7575

76-
#endif /* WIN32 */
76+
#endif /* !defined(WIN32) || defined(FRONTEND) */

src/tools/msvc/Mkvcbuild.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ sub mkvcbuild
6969
chklocale.c crypt.c fls.c fseeko.c getrusage.c inet_aton.c random.c
7070
srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c
7171
erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c exec.c noblock.c path.c
72-
pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c quotes.c
72+
pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c pqsignal.c
73+
qsort.c qsort_arg.c quotes.c
7374
sprompt.c tar.c thread.c wait_error.c getopt.c getopt_long.c dirent.c rint.c win32env.c
7475
win32error.c win32setlocale.c);
7576

0 commit comments

Comments
 (0)