1
0
mirror of https://github.com/fumiama/simple-dict.git synced 2026-06-06 18:50:26 +08:00

优化退出

This commit is contained in:
源文雨
2022-10-15 11:36:39 +08:00
parent 9a7563ba3a
commit 525c08ff9e

View File

@@ -576,6 +576,8 @@ static void handle_kill(int signo) {
puts("Handle sigkill/sigterm");
for(int i = 0; i < THREADCNT; i++) {
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
pthread_cond_destroy(&timers[i].tc);
pthread_mutex_destroy(&timers[i].tmc);
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
}
fflush(stdout);
@@ -644,6 +646,8 @@ static void handle_int(int signo) {
puts("Keyboard interrupted");
for(int i = 0; i < THREADCNT; i++) {
if(timers[i].thread) pthread_kill(timers[i].thread, SIGQUIT);
pthread_cond_destroy(&timers[i].tc);
pthread_mutex_destroy(&timers[i].tmc);
if(timers[i].timerthread) pthread_kill(timers[i].timerthread, SIGQUIT);
}
fflush(stdout);