mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-09 09:19:09 +02:00
mutex fixes
We need to make sure that should_run is protected by the mutex.
This commit is contained in:
parent
1750b92cfb
commit
633743117c
1 changed files with 4 additions and 0 deletions
4
signal.c
4
signal.c
|
|
@ -46,14 +46,18 @@ void *signal_thread(void *arg)
|
|||
sigaction(SIGINT, &temp, NULL);
|
||||
sigaction(SIGTERM, &temp, NULL);
|
||||
|
||||
pthread_mutex_lock(&queue_guard);
|
||||
while(should_run) {
|
||||
pthread_mutex_unlock(&queue_guard);
|
||||
sigfillset(&sigset);
|
||||
sigwait(&sigset, &sig);
|
||||
switch (sig) {
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
printf("This is where we shut down.\n");
|
||||
pthread_mutex_lock(&queue_guard);
|
||||
should_run = 0;
|
||||
pthread_mutex_unlock(&queue_guard);
|
||||
break;
|
||||
default:
|
||||
printf("espeakup caught signal %d\n", sig);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue