Remove tmp files on SIGINT

This allows the use of Ctrl-C without leaving stale files behind which
need to be deleted
This commit is contained in:
scorpion-26 2023-07-14 19:46:27 +02:00
parent fcf4d75ea0
commit 43dd0777a8

View file

@ -33,8 +33,20 @@ void OpenAudioFlyin(Window& window, int32_t monitor, AudioFlyin::Type type)
} }
} }
void CloseTmpFiles(int sig)
{
if (tmpFileOpen)
{
remove(audioTmpFilePath);
remove(bluetoothTmpFilePath);
}
if (sig != 0)
exit(1);
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
signal(SIGINT, CloseTmpFiles);
System::Init(); System::Init();
int32_t monitor = -1; int32_t monitor = -1;
@ -92,11 +104,6 @@ int main(int argc, char** argv)
window.Run(); window.Run();
System::FreeResources(); System::FreeResources();
if (tmpFileOpen) CloseTmpFiles(0);
{
remove(audioTmpFilePath);
LOG("Remove bt");
remove(bluetoothTmpFilePath);
}
return 0; return 0;
} }