Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b60db7

Browse files
Handle SIGTERM in pg_receivewal and pg_recvlogical
In pg_receivewal, compressed output is only flushed on clean exits. Thereason to support SIGTERM as well as SIGINT (which is currently handled)is that pg_receivewal might well be running as a daemon, and systemd'sdefault KillSignal is SIGTERM.Since pg_recvlogical is also supposed to run as a daemon, teach it aboutSIGTERM as well and update the documentation to match. While in there,change pg_receivewal's time_to_stop to be sig_atomic_t like it is inpg_recvlogical.Author: Christoph Berg <myon@debian.org>Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/Yvo/5No5S0c4EFMj@msg.df7cb.de
1 parent0e73327 commit8b60db7

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

‎doc/src/sgml/ref/pg_receivewal.sgml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ PostgreSQL documentation
118118

119119
<para>
120120
In the absence of fatal errors, <application>pg_receivewal</application>
121-
will run until terminated by the <systemitem>SIGINT</systemitem> signal
122-
(<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>).
121+
will run until terminated by the <systemitem>SIGINT</systemitem>
122+
(<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>)
123+
or <systemitem>SIGTERM</systemitem> signal.
123124
</para>
124125
</refsect1>
125126

@@ -457,7 +458,8 @@ PostgreSQL documentation
457458

458459
<para>
459460
<application>pg_receivewal</application> will exit with status 0 when
460-
terminated by the <systemitem>SIGINT</systemitem> signal. (That is the
461+
terminated by the <systemitem>SIGINT</systemitem> or
462+
<systemitem>SIGTERM</systemitem> signal. (That is the
461463
normal way to end it. Hence it is not an error.) For fatal errors or
462464
other signals, the exit status will be nonzero.
463465
</para>

‎doc/src/sgml/ref/pg_recvlogical.sgml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ PostgreSQL documentation
4646
a slot without consuming it, use
4747
<link linkend="functions-replication"><function>pg_logical_slot_peek_changes</function></link>.
4848
</para>
49+
50+
<para>
51+
In the absence of fatal errors, <application>pg_recvlogical</application>
52+
will run until terminated by the <systemitem>SIGINT</systemitem>
53+
(<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>)
54+
or <systemitem>SIGTERM</systemitem> signal.
55+
</para>
4956
</refsect1>
5057

5158
<refsect1>
@@ -407,6 +414,17 @@ PostgreSQL documentation
407414
</para>
408415
</refsect1>
409416

417+
<refsect1>
418+
<title>Exit Status</title>
419+
<para>
420+
<application>pg_recvlogical</application> will exit with status 0 when
421+
terminated by the <systemitem>SIGINT</systemitem> or
422+
<systemitem>SIGTERM</systemitem> signal. (That is the
423+
normal way to end it. Hence it is not an error.) For fatal errors or
424+
other signals, the exit status will be nonzero.
425+
</para>
426+
</refsect1>
427+
410428
<refsect1>
411429
<title>Environment</title>
412430

‎src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static intverbose = 0;
4545
staticintcompresslevel=0;
4646
staticintnoloop=0;
4747
staticintstandby_message_timeout=10*1000;/* 10 sec = default */
48-
staticvolatilebooltime_to_stop= false;
48+
staticvolatilesig_atomic_ttime_to_stop= false;
4949
staticbooldo_create_slot= false;
5050
staticboolslot_exists_ok= false;
5151
staticbooldo_drop_slot= false;
@@ -673,13 +673,13 @@ StreamLog(void)
673673
}
674674

675675
/*
676-
* Whensigint is called, just tell the system to exit at the next possible
677-
* moment.
676+
* WhenSIGINT/SIGTERM are caught, just tell the system to exit at the next
677+
*possiblemoment.
678678
*/
679679
#ifndefWIN32
680680

681681
staticvoid
682-
sigint_handler(intsignum)
682+
sigexit_handler(intsignum)
683683
{
684684
time_to_stop= true;
685685
}
@@ -905,7 +905,8 @@ main(int argc, char **argv)
905905
* if one is needed, in GetConnection.)
906906
*/
907907
#ifndefWIN32
908-
pqsignal(SIGINT,sigint_handler);
908+
pqsignal(SIGINT,sigexit_handler);
909+
pqsignal(SIGTERM,sigexit_handler);
909910
#endif
910911

911912
/*

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,11 @@ StreamLogicalLog(void)
650650
#ifndefWIN32
651651

652652
/*
653-
* Whensigint is called, just tell the system to exit at the next possible
654-
* moment.
653+
* WhenSIGINT/SIGTERM are caught, just tell the system to exit at the next
654+
*possiblemoment.
655655
*/
656656
staticvoid
657-
sigint_handler(intsignum)
657+
sigexit_handler(intsignum)
658658
{
659659
time_to_abort= true;
660660
}
@@ -922,7 +922,8 @@ main(int argc, char **argv)
922922
* if one is needed, in GetConnection.)
923923
*/
924924
#ifndefWIN32
925-
pqsignal(SIGINT,sigint_handler);
925+
pqsignal(SIGINT,sigexit_handler);
926+
pqsignal(SIGTERM,sigexit_handler);
926927
pqsignal(SIGHUP,sighup_handler);
927928
#endif
928929

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp