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:
William Hubbs 2009-06-25 20:04:42 -05:00
commit 1750b92cfb

View file

@ -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;