mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 11:12:49 +00:00
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:
parent
fcf4d75ea0
commit
43dd0777a8
1 changed files with 13 additions and 6 deletions
19
src/gBar.cpp
19
src/gBar.cpp
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue