summaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/pg_receivexlog.c
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2014-02-09 13:10:14 +0100
committerMagnus Hagander <magnus@hagander.net>2014-02-12 18:45:18 +0100
commit63ab2befe0d2332a5571f46c1a2c0af9447c6a4b (patch)
treec4f88602bed8864d70a9cfbe80d51ad3c35f6e12 /src/bin/pg_basebackup/pg_receivexlog.c
parent1c9acd5c86a71b8ab73bc139eb5e0ad292b9a7d4 (diff)
Kill pg_basebackup background process when exiting
If an error occurs in the foreground (backup) process of pg_basebackup, and we exit in a controlled way, the background process (streaming xlog process) would stay around and keep streaming.
Diffstat (limited to 'src/bin/pg_basebackup/pg_receivexlog.c')
-rw-r--r--src/bin/pg_basebackup/pg_receivexlog.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index 8a702e33880..0f191ce6bb3 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -45,6 +45,13 @@ static void StreamLog();
static bool stop_streaming(XLogRecPtr segendpos, uint32 timeline,
bool segment_finished);
+#define disconnect_and_exit(code) \
+ { \
+ if (conn != NULL) PQfinish(conn); \
+ exit(code); \
+ }
+
+
static void
usage(void)
{