diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml index 4fe9e1a874..5f83ba1893 100644 --- a/doc/src/sgml/ref/pg_receivewal.sgml +++ b/doc/src/sgml/ref/pg_receivewal.sgml @@ -118,8 +118,9 @@ PostgreSQL documentation In the absence of fatal errors, pg_receivewal - will run until terminated by the SIGINT signal - (ControlC). + will run until terminated by the SIGINT + (ControlC) + or SIGTERM signal. @@ -457,7 +458,8 @@ PostgreSQL documentation pg_receivewal will exit with status 0 when - terminated by the SIGINT signal. (That is the + terminated by the SIGINT or + SIGTERM signal. (That is the normal way to end it. Hence it is not an error.) For fatal errors or other signals, the exit status will be nonzero. diff --git a/doc/src/sgml/ref/pg_recvlogical.sgml b/doc/src/sgml/ref/pg_recvlogical.sgml index 1a88225409..6d75b6fa4c 100644 --- a/doc/src/sgml/ref/pg_recvlogical.sgml +++ b/doc/src/sgml/ref/pg_recvlogical.sgml @@ -46,6 +46,13 @@ PostgreSQL documentation a slot without consuming it, use pg_logical_slot_peek_changes. + + + In the absence of fatal errors, pg_recvlogical + will run until terminated by the SIGINT + (ControlC) + or SIGTERM signal. + @@ -407,6 +414,17 @@ PostgreSQL documentation + + Exit Status + + pg_recvlogical will exit with status 0 when + terminated by the SIGINT or + SIGTERM signal. (That is the + normal way to end it. Hence it is not an error.) For fatal errors or + other signals, the exit status will be nonzero. + + + Environment diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c index a6e3387a6d..37c14d1a02 100644 --- a/src/bin/pg_basebackup/pg_receivewal.c +++ b/src/bin/pg_basebackup/pg_receivewal.c @@ -45,7 +45,7 @@ static int verbose = 0; static int compresslevel = 0; static int noloop = 0; static int standby_message_timeout = 10 * 1000; /* 10 sec = default */ -static volatile bool time_to_stop = false; +static volatile sig_atomic_t time_to_stop = false; static bool do_create_slot = false; static bool slot_exists_ok = false; static bool do_drop_slot = false; @@ -673,13 +673,13 @@ StreamLog(void) } /* - * When sigint is called, just tell the system to exit at the next possible - * moment. + * When SIGINT/SIGTERM are caught, just tell the system to exit at the next + * possible moment. */ #ifndef WIN32 static void -sigint_handler(int signum) +sigexit_handler(int signum) { time_to_stop = true; } @@ -905,7 +905,8 @@ main(int argc, char **argv) * if one is needed, in GetConnection.) */ #ifndef WIN32 - pqsignal(SIGINT, sigint_handler); + pqsignal(SIGINT, sigexit_handler); + pqsignal(SIGTERM, sigexit_handler); #endif /* diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 2a4c8b130a..a86739ec12 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -650,11 +650,11 @@ error: #ifndef WIN32 /* - * When sigint is called, just tell the system to exit at the next possible - * moment. + * When SIGINT/SIGTERM are caught, just tell the system to exit at the next + * possible moment. */ static void -sigint_handler(int signum) +sigexit_handler(int signum) { time_to_abort = true; } @@ -922,7 +922,8 @@ main(int argc, char **argv) * if one is needed, in GetConnection.) */ #ifndef WIN32 - pqsignal(SIGINT, sigint_handler); + pqsignal(SIGINT, sigexit_handler); + pqsignal(SIGTERM, sigexit_handler); pqsignal(SIGHUP, sighup_handler); #endif