1 /*-------------------------------------------------------------------------
4 * reliable BSD-style signal(2) routine stolen from RWW who stole it
7 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
12 * src/interfaces/libpq/legacy-pqsignal.c
14 *-------------------------------------------------------------------------
16 #include "postgres_fe.h"
22 * This version of pqsignal() exists only because pre-9.3 releases
23 * of libpq exported pqsignal(), and some old client programs still
24 * depend on that. (Since 9.3, clients are supposed to get it from
27 * Because it is only intended for backwards compatibility, we freeze it
28 * with the semantics it had in 9.2; in particular, this has different
29 * behavior for SIGALRM than the version in src/port/pqsignal.c.
31 * libpq itself does not use this.
34 pqsignal(int signo
, pqsigfunc func
)
40 act
.sa_handler
= func
;
41 sigemptyset(&act
.sa_mask
);
44 act
.sa_flags
|= SA_RESTART
;
47 act
.sa_flags
|= SA_NOCLDSTOP
;
49 if (sigaction(signo
, &act
, &oact
) < 0)
51 return oact
.sa_handler
;
53 return signal(signo
, func
);