@@ -181,6 +181,7 @@ static int sg_finish_io(bool wr, Rq_elem * rep,
static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER;
+static bool shutting_down = false;
static bool do_sync = false;
static bool do_time = false;
static Rq_coll rcoll;
@@ -470,6 +471,8 @@ sig_listen_thread(void * v_clp)
while (1) {
sigwait(&signal_set, &sig_number);
+ if (shutting_down)
+ break;
if (SIGINT == sig_number) {
pr2serr(ME "interrupted by SIGINT\n");
guarded_stop_both(clp);
@@ -1629,8 +1632,10 @@ main(int argc, char * argv[])
}
}
- status = pthread_cancel(sig_listen_thread_id);
- if (0 != status) err_exit(status, "pthread_cancel");
+ shutting_down = true;
+
+ status = pthread_kill(sig_listen_thread_id, SIGINT);
+ if (0 != status) err_exit(status, "pthread_kill");
if (STDIN_FILENO != rcoll.infd)
close(rcoll.infd);