mirror of
https://github.com/fumiama/simple-dict.git
synced 2026-06-06 18:50:26 +08:00
优化退出
This commit is contained in:
4
server.c
4
server.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user