mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Use pqsignal() in contrib programs rather than calling signal(2) directly.
The semantics of signal(2) are more variable than one could wish; in particular, on strict-POSIX platforms the signal handler will be reset to SIG_DFL when the signal is delivered. This demonstrably breaks pg_test_fsync's use of SIGALRM. The other changes I made are not absolutely necessary today, because the called handlers all exit the program anyway. But it seems like a good general practice to use pqsignal() exclusively in Postgres code, now that we have it available everywhere.
This commit is contained in:
parent
b1fae823ee
commit
3c07fbf40b
@ -549,7 +549,7 @@ sighandler(int sig)
|
|||||||
static void
|
static void
|
||||||
sigquit_handler(int sig)
|
sigquit_handler(int sig)
|
||||||
{
|
{
|
||||||
signal(SIGINT, SIG_DFL);
|
pqsignal(SIGINT, SIG_DFL);
|
||||||
kill(getpid(), SIGINT);
|
kill(getpid(), SIGINT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -592,9 +592,9 @@ main(int argc, char **argv)
|
|||||||
*
|
*
|
||||||
* There's no way to trigger failover via signal on Windows.
|
* There's no way to trigger failover via signal on Windows.
|
||||||
*/
|
*/
|
||||||
(void) signal(SIGUSR1, sighandler);
|
(void) pqsignal(SIGUSR1, sighandler);
|
||||||
(void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
|
(void) pqsignal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
|
||||||
(void) signal(SIGQUIT, sigquit_handler);
|
(void) pqsignal(SIGQUIT, sigquit_handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "cdk:lr:s:t:w:")) != -1)
|
while ((c = getopt(argc, argv, "cdk:lr:s:t:w:")) != -1)
|
||||||
|
@ -101,14 +101,14 @@ main(int argc, char *argv[])
|
|||||||
handle_args(argc, argv);
|
handle_args(argc, argv);
|
||||||
|
|
||||||
/* Prevent leaving behind the test file */
|
/* Prevent leaving behind the test file */
|
||||||
signal(SIGINT, signal_cleanup);
|
pqsignal(SIGINT, signal_cleanup);
|
||||||
signal(SIGTERM, signal_cleanup);
|
pqsignal(SIGTERM, signal_cleanup);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
signal(SIGALRM, process_alarm);
|
pqsignal(SIGALRM, process_alarm);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGHUP
|
#ifdef SIGHUP
|
||||||
/* Not defined on win32 */
|
/* Not defined on win32 */
|
||||||
signal(SIGHUP, signal_cleanup);
|
pqsignal(SIGHUP, signal_cleanup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prepare_buf();
|
prepare_buf();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user