@@ -51,6 +51,8 @@ extern "C" {
5151#include < signal.h>
5252}
5353
54+ // TODO: Replace _exit() with return again when https://github.com/jtv/libpqxx/issues/1007 is properly fixed
55+
5456/* make the cerr logger globally accessible so we can emit one last
5557 report on SIGINT */
5658cerr_logger *global_cerr_logger;
@@ -62,7 +64,7 @@ extern "C" void log_handler(int)
6264 global_cerr_logger->report ();
6365 if (global_json_logger)
6466 global_json_logger->report ();
65- exit (1 );
67+ _exit (1 );
6668}
6769
6870int main (int argc, char *argv[])
@@ -109,9 +111,9 @@ int main(int argc, char *argv[])
109111 " --verbose emit progress output" << endl <<
110112 " --version print version information and exit" << endl <<
111113 " --help print available command line options and exit" << endl;
112- return 0 ;
114+ _exit ( 0 ) ;
113115 } else if (options.count (" version" )) {
114- return 0 ;
116+ _exit ( 0 ) ;
115117 }
116118
117119 try
@@ -122,15 +124,15 @@ int main(int argc, char *argv[])
122124 schema = make_shared<schema_sqlite>(options[" sqlite" ], options.count (" exclude-catalog" ));
123125#else
124126 cerr << " Sorry, " PACKAGE_NAME " was compiled without SQLite support." << endl;
125- return 1 ;
127+ _exit ( 1 ) ;
126128#endif
127129 }
128130 else if (options.count (" monetdb" )) {
129131#ifdef HAVE_MONETDB
130132 schema = make_shared<schema_monetdb>(options[" monetdb" ]);
131133#else
132134 cerr << " Sorry, " PACKAGE_NAME " was compiled without MonetDB support." << endl;
133- return 1 ;
135+ _exit ( 1 ) ;
134136#endif
135137 }
136138 else
@@ -169,7 +171,7 @@ int main(int argc, char *argv[])
169171 schema = make_shared<schema_pqxx>(options[" target" ], options.count (" exclude-catalog" ), options.count (" dump-state" ), options.count (" read-state" ));
170172
171173 if (options.count (" dump-state" )) {
172- return 0 ;
174+ _exit ( 0 ) ;
173175 }
174176
175177 if (options.count (" log-to" ))
@@ -202,7 +204,7 @@ int main(int argc, char *argv[])
202204
203205 if (queries_generated >= max_queries) {
204206 std::cout << data.dump () << std::endl;
205- return 0 ;
207+ _exit ( 0 ) ;
206208 }
207209 }
208210 }
@@ -214,15 +216,15 @@ int main(int argc, char *argv[])
214216 dut = make_shared<dut_sqlite>(options[" sqlite" ]);
215217#else
216218 cerr << " Sorry, " PACKAGE_NAME " was compiled without SQLite support." << endl;
217- return 1 ;
219+ _exit ( 1 ) ;
218220#endif
219221 }
220222 else if (options.count (" monetdb" )) {
221223#ifdef HAVE_MONETDB
222224 dut = make_shared<dut_monetdb>(options[" monetdb" ]);
223225#else
224226 cerr << " Sorry, " PACKAGE_NAME " was compiled without MonetDB support." << endl;
225- return 1 ;
227+ _exit ( 1 ) ;
226228#endif
227229 }
228230 else
@@ -239,7 +241,7 @@ int main(int argc, char *argv[])
239241 global_cerr_logger->report ();
240242 if (global_json_logger)
241243 global_json_logger->report ();
242- return 0 ;
244+ _exit ( 0 ) ;
243245 }
244246
245247 /* Invoke top-level production to generate AST */
@@ -280,6 +282,6 @@ int main(int argc, char *argv[])
280282 }
281283 catch (const exception &e) {
282284 cerr << e.what () << endl;
283- return 1 ;
285+ _exit ( 1 ) ;
284286 }
285287}
0 commit comments