@@ -23,7 +23,7 @@ static bool test_server_conn(ClusterInfo *cluster, int timeout);
23
23
*
24
24
* Connects to the desired database on the designated server.
25
25
* If the connection attempt fails, this function logs an error
26
- * message and calls exit_nicely () to kill the program.
26
+ * message and calls exit () to kill the program.
27
27
*/
28
28
PGconn *
29
29
connectToServer (ClusterInfo * cluster , const char * db_name )
@@ -45,7 +45,8 @@ connectToServer(ClusterInfo *cluster, const char *db_name)
45
45
if (conn )
46
46
PQfinish (conn );
47
47
48
- exit_nicely (true);
48
+ printf ("Failure, exiting\n" );
49
+ exit (1 );
49
50
}
50
51
51
52
return conn ;
@@ -57,7 +58,7 @@ connectToServer(ClusterInfo *cluster, const char *db_name)
57
58
*
58
59
* Formats a query string from the given arguments and executes the
59
60
* resulting query. If the query fails, this function logs an error
60
- * message and calls exit_nicely () to kill the program.
61
+ * message and calls exit () to kill the program.
61
62
*/
62
63
PGresult *
63
64
executeQueryOrDie (PGconn * conn , const char * fmt ,...)
@@ -81,8 +82,8 @@ executeQueryOrDie(PGconn *conn, const char *fmt,...)
81
82
PQerrorMessage (conn ));
82
83
PQclear (result );
83
84
PQfinish (conn );
84
- exit_nicely (true );
85
- return NULL ; /* Never get here, but keeps compiler happy */
85
+ printf ( "Failure, exiting\n" );
86
+ exit ( 1 );
86
87
}
87
88
else
88
89
return result ;
@@ -152,18 +153,41 @@ get_major_server_version(ClusterInfo *cluster)
152
153
}
153
154
154
155
156
+ static void
157
+ #ifdef HAVE_ATEXIT
158
+ stop_postmaster_atexit (void )
159
+ #else
160
+ stop_postmaster_on_exit (int exitstatus , void * arg )
161
+ #endif
162
+ {
163
+ stop_postmaster (true, true);
164
+
165
+ }
166
+
167
+
155
168
void
156
169
start_postmaster (ClusterInfo * cluster , bool quiet )
157
170
{
158
171
char cmd [MAXPGPATH ];
159
172
const char * bindir ;
160
173
const char * datadir ;
161
174
unsigned short port ;
175
+ bool exit_hook_registered = false;
162
176
163
177
bindir = cluster -> bindir ;
164
178
datadir = cluster -> pgdata ;
165
179
port = cluster -> port ;
166
180
181
+ if (!exit_hook_registered )
182
+ {
183
+ #ifdef HAVE_ATEXIT
184
+ atexit (stop_postmaster_atexit );
185
+ #else
186
+ on_exit (stop_postmaster_on_exit );
187
+ #endif
188
+ exit_hook_registered = true;
189
+ }
190
+
167
191
/*
168
192
* On Win32, we can't send both pg_upgrade output and pg_ctl output to the
169
193
* same file because we get the error: "The process cannot access the file
0 commit comments