/* Function headers */
static void usage(void);
+static void disconnect_and_exit(int code);
static void verify_dir_is_empty_or_create(char *dirname);
static void progress_report(int tablespacenum, const char *filename, bool force);
static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline,
bool segment_finished);
+
+static void disconnect_and_exit(int code)
+{
+ if (conn != NULL)
+ PQfinish(conn);
+
+#ifndef WIN32
+ /*
+ * On windows, our background thread dies along with the process.
+ * But on Unix, if we have started a subprocess, we want to kill
+ * it off so it doesn't remain running trying to stream data.
+ */
+ if (bgchild> 0)
+ kill(bgchild, SIGTERM);
+#endif
+
+ exit(code);
+}
+
+
#ifdef HAVE_LIBZ
static const char *
get_gz_error(gzFile gzf)
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)
{
/* Connection kept global so we can disconnect easily */
extern PGconn *conn;
-#define disconnect_and_exit(code) \
- { \
- if (conn != NULL) PQfinish(conn); \
- exit(code); \
- }
-
extern PGconn *GetConnection(void);