Bug: pipedal doesn't always shut down cleanly.

This commit is contained in:
Robin Davies
2024-09-05 13:06:37 -04:00
parent 7774dc06e6
commit 3a30c4f68a
2 changed files with 53 additions and 42 deletions
+20 -14
View File
@@ -220,8 +220,28 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS; // tell systemd not to auto-restart.
}
}
// only accept signals on the main thread.
// block now so that threads spawned by model inherit the block mask.
int sig;
sigset_t sigSet;
int s;
sigemptyset(&sigSet);
sigaddset(&sigSet, SIGINT);
sigaddset(&sigSet, SIGTERM);
sigaddset(&sigSet, SIGUSR1);
s = pthread_sigmask(SIG_BLOCK, &sigSet, NULL);
if (s != 0)
{
throw std::logic_error("pthread_sigmask failed.");
}
PiPedalModel model;
model.SetRestartListener(
[]()
{
@@ -243,20 +263,6 @@ int main(int argc, char *argv[])
model.WaitForAudioDeviceToComeOnline();
// only accept signals on the main thread.
int sig;
sigset_t sigSet;
int s;
sigemptyset(&sigSet);
sigaddset(&sigSet, SIGINT);
sigaddset(&sigSet, SIGTERM);
sigaddset(&sigSet, SIGUSR1);
s = pthread_sigmask(SIG_BLOCK, &sigSet, NULL);
if (s != 0)
{
throw std::logic_error("pthread_sigmask failed.");
}
#if JACK_HOST
if (systemd)