mirror of
https://github.com/linux-speakup/espeakup.git
synced 2026-08-09 09:19:09 +02:00
fixed signal handling issue
The signal handler stopped working after I moved the initialization calls to the main function. Creating the signal handler thread first fixed this issue.
This commit is contained in:
parent
eb74a3ce17
commit
1750b92cfb
1 changed files with 16 additions and 15 deletions
31
espeakup.c
31
espeakup.c
|
|
@ -104,6 +104,21 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* create the signal processing thread here. */
|
||||
err = pthread_create(&signal_thread_id, NULL, signal_thread, NULL);
|
||||
if (err != 0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the signal mask which will be the default for all threads.
|
||||
* We are handling sigint and sigterm, so block them.
|
||||
*/
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigaddset(&sigset, SIGTERM);
|
||||
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
||||
|
||||
/* Initialize espeak */
|
||||
if (initialize_espeak(&s) < 0) {
|
||||
return 2;
|
||||
|
|
@ -120,21 +135,6 @@ int main(int argc, char **argv)
|
|||
return 5;
|
||||
}
|
||||
|
||||
/* create the signal processing thread here. */
|
||||
err = pthread_create(&signal_thread_id, NULL, signal_thread, NULL);
|
||||
if (err != 0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the signal mask which will be the default for all threads.
|
||||
* We are handling sigint and sigterm, so block them.
|
||||
*/
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGINT);
|
||||
sigaddset(&sigset, SIGTERM);
|
||||
sigprocmask(SIG_BLOCK, &sigset, NULL);
|
||||
|
||||
/* Spawn our softsynth thread. */
|
||||
err = pthread_create(&softsynth_thread_id, NULL, softsynth_thread, &s);
|
||||
if (err != 0) {
|
||||
|
|
@ -153,6 +153,7 @@ int main(int argc, char **argv)
|
|||
pthread_join(espeak_thread_id, NULL);
|
||||
|
||||
espeak_Terminate();
|
||||
close_softsynth();
|
||||
if ( ! debug)
|
||||
unlink(pidPath);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue