3637: Remove fifo file on shutdown r=heinrich5991 a=def-

Helps with the official servers.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-02-23 18:12:41 +00:00 committed by GitHub
commit 0c1f4cbad4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -19,36 +19,40 @@ void CFifo::Init(IConsole *pConsole, char *pFifoFile, int Flag)
if(pFifoFile[0] == '\0')
return;
str_copy(m_aFilename, pFifoFile, sizeof(m_aFilename));
m_Flag = Flag;
mkfifo(pFifoFile, 0600);
mkfifo(m_aFilename, 0600);
struct stat Attribute;
stat(pFifoFile, &Attribute);
stat(m_aFilename, &Attribute);
if(!S_ISFIFO(Attribute.st_mode))
{
dbg_msg("fifo", "'%s' is not a fifo, removing", pFifoFile);
fs_remove(pFifoFile);
mkfifo(pFifoFile, 0600);
stat(pFifoFile, &Attribute);
dbg_msg("fifo", "'%s' is not a fifo, removing", m_aFilename);
fs_remove(m_aFilename);
mkfifo(m_aFilename, 0600);
stat(m_aFilename, &Attribute);
if(!S_ISFIFO(Attribute.st_mode))
{
dbg_msg("fifo", "can't remove file '%s', quitting", pFifoFile);
dbg_msg("fifo", "can't remove file '%s', quitting", m_aFilename);
exit(2);
}
}
m_File = open(pFifoFile, O_RDONLY | O_NONBLOCK);
m_File = open(m_aFilename, O_RDONLY | O_NONBLOCK);
if(m_File < 0)
dbg_msg("fifo", "can't open file '%s'", pFifoFile);
dbg_msg("fifo", "can't open file '%s'", m_aFilename);
}
void CFifo::Shutdown()
{
if(m_File >= 0)
{
close(m_File);
fs_remove(m_aFilename);
}
}
void CFifo::Update()

View file

@ -8,6 +8,7 @@
class CFifo
{
IConsole *m_pConsole;
char m_aFilename[MAX_PATH_LENGTH];
int m_Flag;
int m_File;