diff --git a/src/engine/shared/fifoconsole.cpp b/src/engine/shared/fifoconsole.cpp index fcfdce39d..2b0f2890c 100644 --- a/src/engine/shared/fifoconsole.cpp +++ b/src/engine/shared/fifoconsole.cpp @@ -1,14 +1,15 @@ #include "fifoconsole.h" +#if defined(CONF_FAMILY_UNIX) + #include #include -#if defined(CONF_FAMILY_UNIX) - #include #include #include +#include static LOCK gs_FifoLock = 0; static volatile bool gs_stopFifoThread = false; @@ -40,7 +41,11 @@ void FifoConsole::ListenFifoThread(void *pUser) FifoConsole *pData = (FifoConsole *)pUser; if(!gs_FifoLock) - return; + { + dbg_msg("fifo", "FIFO not properly initialized"); + exit(2); + } + lock_wait(gs_FifoLock); if(gs_stopFifoThread) return; @@ -50,10 +55,21 @@ void FifoConsole::ListenFifoThread(void *pUser) struct stat attribute; stat(pData->m_pFifoFile, &attribute); - lock_unlock(gs_FifoLock); - if(!S_ISFIFO(attribute.st_mode)) - return; + { + dbg_msg("fifo", "'%s' is not a FIFO, removing", pData->m_pFifoFile); + fs_remove(pData->m_pFifoFile); + mkfifo(pData->m_pFifoFile, 0600); + stat(pData->m_pFifoFile, &attribute); + + if(!S_ISFIFO(attribute.st_mode)) + { + dbg_msg("fifo", "Can't remove file, quitting"); + exit(2); + } + } + + lock_unlock(gs_FifoLock); std::ifstream f; char aBuf[8192];